Re: Lazy sequence transformation with item merge

2012-01-17 Thread Ulrich Küttler
Thank you for these solutions. You helped me a lot to get a tiny bit of clojure. This is indeed a different way to think about problems. At least it feels different to me. On Mon, Jan 16, 2012 at 11:49 PM, Meikel Brandmeyer wrote: > Hi, > > here another, slightly different, although in the core s

Re: Lazy sequence transformation with item merge

2012-01-17 Thread Cedric Greevey
On Tue, Jan 17, 2012 at 12:20 AM, Brandon Harvey wrote: > Sorry to be naive, but can I ask why you folks are not using recur? Because we're using lazy-seq instead, which ends up having a similar effect to trampoline (the "recursion" actually winds up as a succession of calls to the function insid

Re: Lazy sequence transformation with item merge

2012-01-17 Thread Brandon Harvey
Sorry to be naive, but can I ask why you folks are not using recur? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with y

Re: Lazy sequence transformation with item merge

2012-01-16 Thread Meikel Brandmeyer
Hi, here another, slightly different, although in the core similar solution. (defn pair-seq [lines] (lazy-seq (when-let [lines (seq lines)] (let [line (first lines) lines (next lines) equal-sign (.indexOf line "=") contd (take-whil

Re: Lazy sequence transformation with item merge

2012-01-16 Thread Cedric Greevey
On Mon, Jan 16, 2012 at 5:28 PM, Cedric Greevey wrote: > If you want a map, (into {} (extract ...)). The obvious input source > is a line-seq obtained somehow. If you want spaces or newlines at the > concatenation sites (e.g. "value3 takes some more lines as well" or > "value3\ntakes some more lin

Re: Lazy sequence transformation with item merge

2012-01-16 Thread Cedric Greevey
Something like: (defn skv [str] (seq (.split str " = " 2))) (defn second-bit-not-equal-sign? [str] (not (second (skv str (defn extract* [lseq] (when lseq (lazy-seq (let [[f & r] lseq] (if (second-bit-not-equal-sign? f) (throw (Exception. "no key here"))) (let

Lazy sequence transformation with item merge

2012-01-16 Thread Ulrich Küttler
Hi all, I am looking for a function that gives me a lazy sequence from a simple key, value file. Keys are words at the beginning of a line. Value start after a key and can span multiple lines. Thus, a file looks something like: key1 = value1 is there and continues key2 = new value key3 = value3 t