PLaneT: combinators.ss
Carl Eastlund updated his library of combinator functions combinators.ss a few days ago.
It contains some classics such as curry and constant, but also includes an "applying" compose as well as map2. The map2 works the same way as map, but the mapper function must return two values.
The functions curry and constant are special cases of Sebastian Egner's cut from srfi-26. The names curry and constant are easier on the eyes though.
It contains some classics such as curry and constant, but also includes an "applying" compose as well as map2. The map2 works the same way as map, but the mapper function must return two values.
The functions curry and constant are special cases of Sebastian Egner's cut from srfi-26. The names curry and constant are easier on the eyes though.
> (require (planet "combinators.ss" ("cce" "combinators.plt" 1 1)))
> ((curry list 1 2) 3 4)
(1 2 3 4)
> ((constant 3))
3
> (define (q+r n)
(list (quotient n 3)
(remainder n 3)))
> ((compose/apply * q+r) 8)
4
> (map2 quotient/remainder
(list 1 2 3 4 5)
(list 3 3 3 3 3))
(0 0 1 1 1)
(1 2 0 1 2)
0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home