Positional Partial application for Clojure
Posted: Fri Oct 31, 2008 7:19 am
Here is a quick little utility for positional-partial application in clojure, similar to cut from srfi 26 for Scheme, but a function, rather than syntax.
If for some reason you need to pass a :_ keyword to a function you can specify another "leave open" sigil of any value by adding it to the function call.
This code is available from my mercurial repository hosted at freeHg. Just:
And add that to your classpath. Then you can use it by
Maybe someone besides me will find it useful.
Code: Select all
(map (plx cons 'head :_) '((1 2) (3 4) (5 6)))
;;=> ((head 1 2) (head 3 4) (head 5 6))
(map (plx list 'head :_ 'end) '( middle mean meat ))
;;=> ((head middle end) (head mean end) (head meat end))
Code: Select all
((plx :pass + :pass 1) 4)
;;=> 5
Code: Select all
hg clone http://freehg.org/u/VincentToups/clojure-libs/
Code: Select all
(clojure/ns my-code (:use toups.functional))
;;; Clojure Code