Doug Coleman 2007-12-31 11:51:58 -06:00
commit aec422a744
3 changed files with 16 additions and 7 deletions

View File

@ -161,3 +161,8 @@ MACRO: map-call-with2 ( quots -- )
r> length [ narray ] curry append ; r> length [ narray ] curry append ;
MACRO: map-exec-with ( words -- ) [ 1quotation ] map [ map-call-with ] curry ; 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 ;

View File

@ -2,18 +2,18 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: parser kernel sequences words effects inference.transforms USING: parser kernel sequences words effects inference.transforms
combinators assocs definitions quotations namespaces ; combinators assocs definitions quotations namespaces memoize ;
IN: macros IN: macros
: (:) : (:) ( -- word definition effect-in )
CREATE dup reset-generic parse-definition CREATE dup reset-generic parse-definition
over "declared-effect" word-prop effect-in length ; over "declared-effect" word-prop effect-in length ;
: (MACRO:) : (MACRO:) ( word definition effect-in -- )
>r >r 2dup "macro" set-word-prop
2dup "macro" set-word-prop 2dup over "declared-effect" word-prop memoize-quot
2dup [ call ] append define-compound [ call ] append define-compound
r> define-transform ; r> define-transform ;
: MACRO: : MACRO:

View File

@ -1,7 +1,7 @@
! Copyright (C) 2007 Slava Pestov, Daniel Ehrenberg. ! Copyright (C) 2007 Slava Pestov, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel hashtables sequences arrays words namespaces USING: kernel hashtables sequences arrays words namespaces
parser math assocs effects definitions ; parser math assocs effects definitions quotations ;
IN: memoize IN: memoize
: packer ( n -- quot ) : packer ( n -- quot )
@ -46,3 +46,7 @@ PREDICATE: compound memoized "memoize" word-prop ;
M: memoized definer drop \ MEMO: \ ; ; M: memoized definer drop \ MEMO: \ ; ;
M: memoized definition "memo-quot" word-prop ; 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 ;