[newbie] filter confusion

2011-09-20 Thread qhfgva
I'm working through some puzzle problems to help get up to speed on clojure. Generally I've been able to pound on something for a while and get the moment of enlightenment but for some reason this seemingly simple item is stumping me. (FWIW, the puzzle in question is the crossing a bridge at nigh

Re: filter confusion

2011-09-20 Thread qhfgva
On Sep 20, 7:02 am, Chouser wrote: > On Mon, Sep 19, 2011 at 2:20 PM, qhfgva wrote: > > I'm working through some puzzle problems to help get up to speed on > > clojure.  Generally I've been able to pound on something for a while > > and get the moment of enlight

break-on-gaps - just curious if there is a more idiomatic way to do this

2011-09-28 Thread qhfgva
I've been working on problems from "Programming Challenges" (Skiena) to learn clojure. As part of a problem I developed the following routine. I sort of scare myself how natural thinking in reduce is getting, but I was wondering if there is a more clever/idiomatic way to solve this problem. (def

Re: break-on-gaps - just curious if there is a more idiomatic way to do this

2011-09-29 Thread qhfgva
Thanks. That's helps me think about when/how to use lazy-seq On Sep 28, 2:00 pm, Nathan Sorenson wrote: > If you were feeling so inclined, you could structure this as a lazy sequence > (like 'partition' does) > > (defn lazy-break >   [coll] >   (letfn [(break-paired [pairs] >             (lazy-s

Re: break-on-gaps - just curious if there is a more idiomatic way to do this

2011-09-29 Thread qhfgva
t; if you're interested. Using that as a primitive, your break-on-gaps > function is simple: > > user> (partition-between (fn [[a b]] (not= a (dec b))) [1 2 3 5 6 7 8 > 10 20 21]) > ([1 2 3] [5 6 7 8] [10] [20 21]) > > On Sep 28, 11:39 am,qhfgva wrote: > > &

confusion about refs

2011-10-12 Thread qhfgva
I was trying out an example from Practical Clojure and I don't understand why I get different results below? Can someone enlighten me? user=> @my-contacts [# # #] user=> (:fname (first @my-contacts)) nil user=> ((first @my-contacts) :fname) "Luke" Why would the placement of :fname change how it