]> gitweb.factorcode.org Git - factor.git/blob - extra/models/combinators/templates/templates.factor
ui: some cleanup of old factor code
[factor.git] / extra / models / combinators / templates / templates.factor
1 USING: fry functors generalizations kernel macros sequences
2 sequences.generalizations ;
3 IN: models.combinators.templates
4 FROM: models.combinators => <collection> #1 ;
5 <FUNCTOR: fmaps ( W -- )
6 W        IS ${W}
7 w-n      DEFINES ${W}-n
8 w-2      DEFINES 2${W}
9 w-3      DEFINES 3${W}
10 w-4      DEFINES 4${W}
11 w-n*     DEFINES ${W}-n*
12 w-2*     DEFINES 2${W}*
13 w-3*     DEFINES 3${W}*
14 w-4*     DEFINES 4${W}*
15 WHERE
16 MACRO: w-n ( int -- quot )
17     dup '[ [ _ narray <collection> ] dip [ _ firstn ] prepend W ] ;
18 : w-2 ( a b quot -- mapped ) 2 w-n ; inline
19 : w-3 ( a b c quot -- mapped ) 3 w-n ; inline
20 : w-4 ( a b c d quot -- mapped ) 4 w-n ; inline
21 MACRO: w-n* ( int -- quot )
22     dup '[ [ _ narray <collection> #1 ] dip [ _ firstn ] prepend W ] ;
23 : w-2* ( a b quot -- mapped ) 2 w-n* ; inline
24 : w-3* ( a b c quot -- mapped ) 3 w-n* ; inline
25 : w-4* ( a b c d quot -- mapped ) 4 w-n* ; inline
26 ;FUNCTOR>