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

http://github.com/abeaumont/factor · Factor · 23 lines · 23 code · 0 blank · 0 comment · 1 complexity · 83d554dc895c8a392ed68c72e7126ea2 MD5 · raw file

  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