memoize: use unsafe words.

db4
John Benediktsson 2012-07-17 16:24:30 -07:00
parent 6a08de2203
commit 632f0d9810
1 changed files with 2 additions and 2 deletions

View File

@ -15,7 +15,7 @@ IN: memoize
: [nsequence] ( length exemplar -- quot )
[ [ [ 1 - ] keep ] dip '[ _ _ _ new-sequence ] ]
[ drop [ [ set-nth-unsafe ] 2keep [ 1 - ] dip ] (n*quot) ] 2bi
[ nip ] 3append ;
[ nip ] 3append ;
: [firstn] ( length -- quot )
[ 0 swap ] swap
@ -29,7 +29,7 @@ IN: memoize
: unpacker ( seq -- quot )
length dup 4 <=
[ { [ drop ] [ ] [ first2 ] [ first3 ] [ first4 ] } nth ]
[ { [ drop ] [ ] [ first2-unsafe ] [ first3-unsafe ] [ first4-unsafe ] } nth ]
[ [firstn] ] if ;
: pack/unpack ( quot effect -- newquot )