core.match question: guarding against nil in map patterns

2014-06-25 Thread rrs
Does the following snippet show the intended behavior? user=> (def not-nil? (complement nil?)) > #'user/not-nil? > user=> (defn f [x] (match [x] [{:a (ma :guard not-nil?)}] ma :else > :no-match)) > #'user/f > user=> (f {:a 1}) > 1 > user=> (f {:b 1}) > nil > user=> (f {:a nil}) > :no-match > user

Re: How to transform one data structure to another data structure?

2014-02-04 Thread rrs
You can start here http://clojuredocs.org/clojure_core/clojure.core/group-by it should be pretty easy to get it working from there. On Tuesday, February 4, 2014 4:06:14 PM UTC-5, Thomas wrote: > > Hi all, > > I was wondering how I can convert the following data structure to the one > below: > >

partial function revisited (exercise in macros)

2014-02-03 Thread rrs
Hello all, For various reasons, and despite the convenience of anonymous functions, I'd like to have a proper positional parameter binding partial function application. (Actually, I'd like to have by-name parameter binding, but that's another story.) For example, the following seems to work: (

Re: destructuring vectors with :or

2013-04-12 Thread rrs
Clojure documentation only talks about :or followed by a map (from http://clojure.org/special_forms ): > Also optionally, an *:or* key in the binding form followed by another > map may be used to supply default values for some or all of the keys if > they are not found in the init-expr: > > (l