Re: A better flatten

2009-09-02 Thread Meikel Brandmeyer
On Sep 3, 1:13 am, Sudish Joseph wrote: > (defn flatten-2 [lst] >   (lazy-seq >     (if-let [x (first lst)] >       (let [xs (rest lst)] >         (if (seq? x) >           (concat (flatten-2 x) (flatten-2 xs)) >           (cons x (flatten-2 xs))) This version is broken: user=> (flatten-2

Re: maplocalleader & vimclojure

2009-09-02 Thread Meikel Brandmeyer
Hi, On Sep 3, 2:21 am, Bokeh Sensei wrote: > vimclojure took me a whole weekend to get started. > it's sensitive to how it's setup, but with no way to automatically > verify the correctness of it. Ok. I give up. Obviously I'm not able to explain how to install VimClojure, neither with the READM

Re: Filter Causing StackOverflowError?

2009-09-02 Thread Krukow
On Sep 2, 7:02 pm, tmountain wrote: > (defn generate-chain [source] >   (loop [the-list (map #(list (first (split-at 2 %)) (last %)) >                       (partition 3 1 (.split (.replace source "\n" " > ") " "))) >          res (hash-map)] >     (if (empty? the-list) >       res >       (rec

Re: A better flatten

2009-09-02 Thread Krukow
On Sep 3, 1:13 am, Sudish Joseph wrote: > The other solutions seem higher level, but it's worth noting that > destructuring -- (let [[x & xs] lst] ...) -- uses next and is therefore > not fully lazy in that you will peek ahead by one into the lazy > sequence, so to speak.  You have to use explic

Re: Filter Causing StackOverflowError?

2009-09-02 Thread John Harrop
On Wed, Sep 2, 2009 at 1:02 PM, tmountain wrote: > > Hi all - I've recently encouraged a friend to start learning Clojure, > and he has written some basic Markov chaining code as a learning > exercise. His code works fine with small sets of input data, but > larger inputs have been causing a Stac

Re: maplocalleader & vimclojure

2009-09-02 Thread Bokeh Sensei
vimclojure took me a whole weekend to get started. it's sensitive to how it's setup, but with no way to automatically verify the correctness of it. Try this in vim: :call vimclojure#Repl.New() If it fails, that probably means the vimclojure plugin can't find the vimclojure jar on the path. In m

Re: Searching the group archives

2009-09-02 Thread Aaron Brooks
Rich, Chouser or other Clojure group admin, It may be helpful to put the search link in the currently unused welcome message section of the group "Home" page. -Aaron On Sat, Aug 29, 2009 at 3:34 PM, Daniel wrote: > > On Sun, Aug 30, 2009 at 1:54 AM, Rich Hickey wrote: >> >> While the "Searc

Re: Order of keys within a map?

2009-09-02 Thread Richard Newman
> Maybe it's premature optimization, but I don't want the overhead of a > sorted map structure when a minimal (and ideally, optimized for few > keys) map will do better. Then you might want to look at struct-map... predefined keys are in a fixed order. --~--~-~--~~~

Ref method getHistoryCount

2009-09-02 Thread Mark Volkmann
Can someone explain why the getHistoryCount method in Ref.java acquires a write lock instead of a read lock? I say in my STM article: "It acquires a write lock instead of a read lock because it walks the history chain to get the count and needs to prevent other threads from modifying the chain wh

Re: A better flatten

2009-09-02 Thread Sudish Joseph
Hi Karl, The other solutions seem higher level, but it's worth noting that destructuring -- (let [[x & xs] lst] ...) -- uses next and is therefore not fully lazy in that you will peek ahead by one into the lazy sequence, so to speak. You have to use explicit first / rest to get that: ;; with de

Re: Searching the group archives

2009-09-02 Thread Emeka
Another way of searching . Instead of "Search this group" use "Search Groups" , and inform google of the group you intend search and your message. Here is an example, re-find group:clojure . Regards, Emeka On Sun, Aug 30, 2009 at 12:19 PM, Emeka wrote: > Thanks, I was about asking for hel

Re: Order of keys within a map?

2009-09-02 Thread Howard Lewis Ship
Maybe it's premature optimization, but I don't want the overhead of a sorted map structure when a minimal (and ideally, optimized for few keys) map will do better. On Tue, Sep 1, 2009 at 11:46 AM, Rob Lachlan wrote: > > As, Patrick Sullivan, said, the built-in sorted-map guarantees that > the key

A better flatten

2009-09-02 Thread Krukow
Hello, At some point I needed at "flatten" function taking a list of atomic elements or nested lists, and producting a "flat" list of only atomic elements (in the same order). It should be lazy. This is what I came up with. Can anyone see a more elegant solution (I feel I am working "low-level" s

Re: A better flatten

2009-09-02 Thread Sean Devlin
It's in c.c.seq-utils You can look up stuff here: http://richhickey.github.com/clojure-contrib/api-index.html On Sep 2, 4:12 pm, tmountain wrote: > I believe the flatten in contrib is defined as follows. I can't > remember which module I found it in. > > (defn flatten >   "Takes any nested com

Backporting clojure.contrib.logging

2009-09-02 Thread Phil Hagelberg
Hello! I've backported contrib's logging.clj library to work with Clojure 1.0. It was just a handful of modifications wrt how the import function worked. I'd like to get it included in the clojure-1.0-compat branch of contrib. Shall I create an assembla ticket and attach my patch there? -Phil

Re: A better flatten

2009-09-02 Thread tmountain
I believe the flatten in contrib is defined as follows. I can't remember which module I found it in. (defn flatten "Takes any nested combination of sequential things (lists, vectors, etc.) and returns their contents as a single, flat sequence. (flatten nil) returns nil." [x] (filter (co

maplocalleader & vimclojure

2009-09-02 Thread ronen
Iv been trying to use the Nailgun functionlity of vimclojure but Im stuck on a silly issue, Im hitting el inside: (println "hello") And nothing happens, same goes for the rest options. In addition its not clear to me how to start the REPL the doc/ README.txt says: "Start a Repl via the |sr| sh

Filter Causing StackOverflowError?

2009-09-02 Thread tmountain
Hi all - I've recently encouraged a friend to start learning Clojure, and he has written some basic Markov chaining code as a learning exercise. His code works fine with small sets of input data, but larger inputs have been causing a StackOverflowError. I've taken a look at the code and suspect t

Re: Is there a cleaner way to filter a map?

2009-09-02 Thread Krukow
On Sep 2, 1:44 am, Richard Newman wrote: > Conrad, > >    (into {} >      (filter (fn [[key val]] >                (even? val)) >      {:dog 5 :cat 4 :mouse 7 :cow 6})) > >    => >    {:cat 4, :cow 6} Or if you like "point-free" style (into {} (filter (comp even? second) {:dog 5

Re: Is there a cleaner way to filter a map?

2009-09-02 Thread Sean Devlin
If you're gonna go point free... ((comp (partial into {}) (partial filter (comp even? val))) {:dog 5 :cat 4 :mouse 7 :cow 6}) On Sep 2, 11:03 am, Krukow wrote: > On Sep 2, 5:02 pm, Krukow wrote: > > > Or if you like "point-free" style > > (into {} > >    (filter (comp even? second

Re: Is there a cleaner way to filter a map?

2009-09-02 Thread Krukow
On Sep 2, 5:02 pm, Krukow wrote: > Or if you like "point-free" style > (into {} >    (filter (comp even? second) >             {:dog 5 :cat 4 :mouse 7 :cow 6})) > => > {:cat 4, :cow 6} Saving a few chars, and perhaps more readable: user> (into {} (filter (comp even? val)