commit
aec422a744
|
@ -161,3 +161,8 @@ MACRO: map-call-with2 ( quots -- )
|
|||
r> length [ narray ] curry append ;
|
||||
|
||||
MACRO: map-exec-with ( words -- ) [ 1quotation ] map [ map-call-with ] curry ;
|
||||
|
||||
MACRO: construct-slots ( assoc tuple-class -- tuple )
|
||||
[ construct-empty ] curry swap [
|
||||
[ dip ] curry swap 1quotation [ keep ] curry compose
|
||||
] { } assoc>map concat compose ;
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
|
||||
USING: parser kernel sequences words effects inference.transforms
|
||||
combinators assocs definitions quotations namespaces ;
|
||||
combinators assocs definitions quotations namespaces memoize ;
|
||||
|
||||
IN: macros
|
||||
|
||||
: (:)
|
||||
: (:) ( -- word definition effect-in )
|
||||
CREATE dup reset-generic parse-definition
|
||||
over "declared-effect" word-prop effect-in length ;
|
||||
|
||||
: (MACRO:)
|
||||
>r
|
||||
2dup "macro" set-word-prop
|
||||
2dup [ call ] append define-compound
|
||||
: (MACRO:) ( word definition effect-in -- )
|
||||
>r 2dup "macro" set-word-prop
|
||||
2dup over "declared-effect" word-prop memoize-quot
|
||||
[ call ] append define-compound
|
||||
r> define-transform ;
|
||||
|
||||
: MACRO:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2007 Slava Pestov, Daniel Ehrenberg.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel hashtables sequences arrays words namespaces
|
||||
parser math assocs effects definitions ;
|
||||
parser math assocs effects definitions quotations ;
|
||||
IN: memoize
|
||||
|
||||
: packer ( n -- quot )
|
||||
|
@ -46,3 +46,7 @@ PREDICATE: compound memoized "memoize" word-prop ;
|
|||
|
||||
M: memoized definer drop \ MEMO: \ ; ;
|
||||
M: memoized definition "memo-quot" word-prop ;
|
||||
|
||||
: memoize-quot ( quot effect -- memo-quot )
|
||||
gensym swap dupd "declared-effect" set-word-prop
|
||||
dup rot define-memoized 1quotation ;
|
||||
|
|
Loading…
Reference in New Issue