]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/models/combinators/templates/templates.factor
d174efcfc583138ca4e6c572580656f952339699
[factor.git] / unmaintained / models / combinators / templates / templates.factor
1 USING: kernel sequences functors fry macros generalizations ;
2 IN: models.combinators.templates
3 FROM: models.combinators => <collection> #1 ;
4 FUNCTOR: fmaps ( W -- )
5 W        IS ${W}
6 w-n      DEFINES ${W}-n
7 w-2      DEFINES 2${W}
8 w-3      DEFINES 3${W}
9 w-4      DEFINES 4${W}
10 w-n*     DEFINES ${W}-n*
11 w-2*     DEFINES 2${W}*
12 w-3*     DEFINES 3${W}*
13 w-4*     DEFINES 4${W}*
14 WHERE
15 MACRO: 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
19 MACRO: 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