PageRenderTime 15ms CodeModel.GetById 9ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/unmaintained/models/combinators/templates/templates.factor

http://github.com/abeaumont/factor
Unknown | 23 lines | 23 code | 0 blank | 0 comment | 0 complexity | 83d554dc895c8a392ed68c72e7126ea2 MD5 | raw file
 1USING: kernel sequences functors fry macros generalizations ;
 2IN: models.combinators.templates
 3FROM: models.combinators => <collection> #1 ;
 4FUNCTOR: fmaps ( W -- )
 5W        IS ${W}
 6w-n      DEFINES ${W}-n
 7w-2      DEFINES 2${W}
 8w-3      DEFINES 3${W}
 9w-4      DEFINES 4${W}
10w-n*     DEFINES ${W}-n*
11w-2*     DEFINES 2${W}*
12w-3*     DEFINES 3${W}*
13w-4*     DEFINES 4${W}*
14WHERE
15MACRO: w-n ( int -- quot ) dup '[ [ _ narray <collection> ] dip [ _ firstn ] prepend W ] ;
16: w-2 ( a b quot -- mapped ) 2 w-n ; inline
17: w-3 ( a b c quot -- mapped ) 3 w-n ; inline
18: w-4 ( a b c d quot -- mapped ) 4 w-n ; inline
19MACRO: w-n* ( int -- quot ) dup '[ [ _ narray <collection> #1 ] dip [ _ firstn ] prepend W ] ;
20: w-2* ( a b quot -- mapped ) 2 w-n* ; inline
21: w-3* ( a b c quot -- mapped ) 3 w-n* ; inline
22: w-4* ( a b c d quot -- mapped ) 4 w-n* ; inline
23;FUNCTOR