Add compiler transform for index with a literal sequenc

db4
Slava Pestov 2009-03-27 20:05:23 -05:00
parent 6b55cd55ef
commit b53960dace
1 changed files with 9 additions and 0 deletions

View File

@ -154,6 +154,15 @@ CONSTANT: bit-member-max 256
dup sequence? [ memq-quot ] [ drop f ] if dup sequence? [ memq-quot ] [ drop f ] if
] 1 define-transform ] 1 define-transform
! Index search
\ index [
dup sequence? [
dup length 4 >= [
dup length zip >hashtable '[ _ at ]
] [ drop f ] if
] [ drop f ] if
] 1 define-transform
! Shuffling ! Shuffling
: nths-quot ( indices -- quot ) : nths-quot ( indices -- quot )
[ [ '[ _ swap nth ] ] map ] [ length ] bi [ [ '[ _ swap nth ] ] map ] [ length ] bi