add a:hash, new a:eq? and a:-eq? using it
FossilOrigin-Name: dfbda4bf2b4a28567bcd65a762aab2d025a94242da26cd857f82d712abe7ec55
This commit is contained in:
parent
20d71b6840
commit
9e030890d2
4 changed files with 754 additions and 786 deletions
|
@ -1669,32 +1669,12 @@ I'm defining a new `a:make` which wraps these.
|
|||
:} (-a) |] |dip |depth |swap |- |n:dec |] |a:make ; immediate
|
||||
~~~
|
||||
|
||||
For comparing arrays, use `a:eq?`. This is written in assembly
|
||||
to aid in performance and reduce size.
|
||||
For comparing arrays, use `a:eq?` or `a:-eq?`.
|
||||
|
||||
~~~
|
||||
{{
|
||||
'Flag var
|
||||
:compare \dufepusw \dufepoeq ;
|
||||
:length \dufere.. ;
|
||||
:next \liadswli `1 `1 \adre.... ;
|
||||
:not-equal \podrdrdr \lire...... `0 ;
|
||||
:loop repeat
|
||||
\pulica.. ^next
|
||||
\lica.... ^compare
|
||||
\lifeanli ^Flag ^Flag \st......
|
||||
\polisuzr `1
|
||||
again ;
|
||||
---reveal---
|
||||
:a:eq? (aa-f)
|
||||
\lilist.. `-1 ^Flag
|
||||
\lica.... ^compare
|
||||
\lixolicc `-1 ^not-equal
|
||||
\lica.... ^length
|
||||
\lica.... ^loop
|
||||
\drdrlife ^Flag ;
|
||||
:a:-eq? (aa-f) a:eq? not ;
|
||||
}}
|
||||
:a:hash (a-n) #5381 swap [ swap #33 * + ] a:for-each ;
|
||||
:a:eq? (aa-f) a:hash swap a:hash eq? ;
|
||||
:a:-eq? (aa-f) a:hash swap a:hash -eq? ;
|
||||
~~~
|
||||
|
||||
Building on these, I implement `a:begins-with?` and `a:ends-with?`
|
||||
|
|
|
@ -22,11 +22,6 @@ existing set in the future.
|
|||
:aa:last (a-n) dup a:length n:dec a:fetch ;
|
||||
|
||||
|
||||
:aa:hash (a-n) #5381 swap [ swap #33 n:mul n:add ] a:for-each ;
|
||||
|
||||
:aa:eq? (aa-f) aa:hash swap aa:hash eq? ;
|
||||
:aa:-eq? (aa-f) aa:hash swap aa:hash -eq? ;
|
||||
|
||||
:a:dup here [ dup a:length comma &comma a:for-each ] dip ;
|
||||
~~~
|
||||
|
||||
|
|
BIN
ngaImage
BIN
ngaImage
Binary file not shown.
1507
vm/nga-c/image.c
1507
vm/nga-c/image.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue