Sorting broken (was: sorted-map-by value)

2008-12-27 Thread kwatford
Sorted maps sort only on keys, sorry. I was going to suggest using (sort-by frest foo) to at least get a sequence in the right order, but it seems like sorting might be broken at the moment? Looks like this response has turned into a bug report... user= (sort [3 1 2])

sorted-map-by value

2008-12-27 Thread kwatford
Oh, nevermind. I hadn't switched my svn over to the Google Code repository, so I was on 1162... up to 1185 and we're ok. So yeah. user= (sort-by frest {:a 2 :b 3 :c 1}) ([:c 1] [:a 2] [:b 3]) On Dec 27, 12:50 pm, kwatford kwatf...@gmail.com wrote: Sorted maps sort only on keys, sorry. I

dissoc-in?

2008-12-19 Thread kwatford
I've been using assoc-in, get-in, etc, to work with nested maps, but I recently needed a dissoc-in to free up unneeded indexes and such. I didn't see one, so does this look about right? (defn dissoc-in [m keys] (if (= (count keys) 1) (dissoc m (first keys)) (let [k (last keys)

Re: “Don’t know how to create ISeq from: Symbol” error

2008-12-15 Thread kwatford
I have the following Clojure code and I'm not sure why it's not working: The short answer is: That's not Clojure code, it is Common Lisp code. Longer answer: Despite having similar-looking syntax, the two are not particularly related. Of the functions/macros you tried to use, I think only and,

Re: A newbie question on Agents and ants

2008-12-15 Thread kwatford
*agent* and a few others have recently been properly documented at http://clojure.org/api Unfortunately this isn't true for all of the 'standard' globals. *in* and *out* don't have entries of their own, though they are mentioned in the functions that use them, so a search within that page will

Set union weirdness

2008-12-14 Thread kwatford
So I have some code that looks somewhat like: (update-in node [:index :x] set/union #{:y}) This seems fine as long as there's already a set in the desired spot. However, since update-in will kindly build the map structure for you if it doesn't already exist, I figured it would be nice not to

Re: Why allow both ({:map 'example} :map) and (:map {:map 'example})?

2008-12-12 Thread kwatford
Maps are functions of their keys because that's what maps are. Keywords are functions of their maps because it is useful. (def foo [{:name Bob, :age 20}, {:name Sue, :age 19}]) (sort-by :age foo) (sort-by :name foo) Note that sort-by doesn't specifically take a keyword or know what maps are.

Re: recur vs. lazy: establishing guidelines

2008-12-10 Thread kwatford
Here is where I am: If your function creates/returns only atoms or   fixed size collections, loop/recur is fine. I don't think you should use the word 'atom' in the discussion in the book. Lisp people will know what you mean, but Clojure's new 'atom' reference type makes that usage confusing

Re: Keyword constraints not enforced

2008-11-25 Thread kwatford
Somewhat related, I noticed that the keyword function doesn't seem to make any attempt at ensuring keywords are even readable. user= (keyword (foo)) :(foo) Is this intended? On Nov 24, 9:26 am, Rich Hickey [EMAIL PROTECTED] wrote: On Nov 23, 9:09 am, James Reeves [EMAIL PROTECTED] wrote: