Re: drop-while for noobs

2010-08-10 Thread Michael Wood
On 9 August 2010 22:16, Alan a...@malloys.org wrote: Weird. I wonder if I was using an outdated version of Clojure or (more likely) assumed from (doc drop-while) that it wouldn't handle false the way I wanted. When doc says not nil should I assume it means neither nil nor false, or should the

drop-while for noobs

2010-08-09 Thread Alan
Hi all, I'm new to the group; I have some experience with both CL and Java, though it's been a while for each. Anyway I really like Clojure as a way of combining the best parts of the two languages, but I'm still getting the hang of it and there are often things that confuse me. For example, I

Re: drop-while for noobs

2010-08-09 Thread Wilson MacGyver
you can do this using partition. let's assume I first define a user= (def a [:w :n :e :s]) #'user/a user= (partition 2 1 (conj a (first a))) ((:w :n) (:n :e) (:e :s) (:s :w)) gives you the pairs you need. then you just need to turn it into hash-map by doing (map #(apply hash-map %)

Re: drop-while for noobs

2010-08-09 Thread Armando Blancas
It works with booleans: user= (drop-while neg? [-3 -2 -1 0 1 2 3 ]) (0 1 2 3) user= (class (neg? -5)) java.lang.Boolean On Aug 9, 12:09 pm, Alan a...@malloys.org wrote: Hi all, I'm new to the group; I have some experience with both CL and Java, though it's been a while for each. Anyway I

Re: drop-while for noobs

2010-08-09 Thread jv-li...@tx.rr.com
On Aug 9, 2:09 pm, Alan a...@malloys.org wrote: Hi all, I'm new to the group Welcome! I wanted to define a ring function, which takes as input N objects, and returns a hash table mapping object N to object N+1 (mod N). I intended to use this to describe a compass object: (ring :w :n :e :s)

Re: drop-while for noobs

2010-08-09 Thread Alan
Also sorry the indentation is so awful. How do I get Google to let me compose/edit in a fixed-width font? On Aug 9, 12:09 pm, Alan a...@malloys.org wrote: Hi all, I'm new to the group; I have some experience with both CL and Java, though it's been a while for each. Anyway I really like Clojure

Re: drop-while for noobs

2010-08-09 Thread Alan
Weird. I wonder if I was using an outdated version of Clojure or (more likely) assumed from (doc drop-while) that it wouldn't handle false the way I wanted. When doc says not nil should I assume it means neither nil nor false, or should the doc for drop-while be updated? user= (doc drop-while)

Re: drop-while for noobs

2010-08-09 Thread Armando Blancas
When doc says not nil should I assume it means neither nil nor false Nope, false won't be taken as nil; in boolean expressions nil evaluates to false. drop-while's doc mentions only nil but since it's the predicate's return value it should be clear enough, I think. -- You received this