Re: REPL vs Script + Regex Problem!

2010-02-03 Thread Michał Marczyk
On 3 February 2010 08:58, Meikel Brandmeyer wrote: > condp was specifically designed to be a scheme-like cond with :>> > support and such. Well, I like condp a lot (really, condp FTW! -- definately worth a define-syntax in Scheme :-)), but it's nothing like Scheme's cond (which is a good thing, a

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Meikel Brandmeyer
Hi, On Feb 3, 1:54 am, Michał Marczyk wrote: > Something I wanted to mention is that this could provide a use case > for an Scheme style cond macro, especially if the processing logic got > more involved -- have a look at my scond if you'd like: > > http://gist.github.com/293212 > > Basically th

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Michał Marczyk
Something I wanted to mention is that this could provide a use case for an Scheme style cond macro, especially if the processing logic got more involved -- have a look at my scond if you'd like: http://gist.github.com/293212 Basically this would allow you to write things like (scond [(re-matches

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Wardrop
(some) definitely seems like the way to go. Now I've got to move onto my next problem, which is totally the number of duplicate files and the bytes they take up. I'm guessing at this point that something like (reduce) will be the way to go. Thanks for all your help. This won't be the last time you

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Michał Marczyk
On 3 February 2010 00:50, ataggart wrote: > It occurs to me you could use 'some instead of nested if-lets: > > (some identity >  [(first (re-matches #"([0-9]+) byte\(null\)each:" line)) >   (first (re-matches #".*(\.[0-9a-zA-Z]+)" line))]) A simplified version: (some #(first (re-matches % line))

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread ataggart
It occurs to me you could use 'some instead of nested if-lets: (some identity [(first (re-matches #"([0-9]+) byte\(null\)each:" line)) (first (re-matches #".*(\.[0-9a-zA-Z]+)" line))]) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to t

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread ataggart
On Feb 2, 3:02 pm, Wardrop wrote: > The problem is, the only output I get is "Finished!". If however, I > run this on the command line, I get a long list of nil's in amongst > the strings "Byte pattern!" and "File pattern!". I expect the nil's > not to show when this is run as a script, but why

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Meikel Brandmeyer
Hi, Am 02.02.2010 um 23:48 schrieb Wardrop: > (for [line (line-seq (reader "C:\\filedupes.txt"))] > (cond >((complement nil?) (re-matches #"([0-9]+) byte\(null\)each:" > line)) > (println "Byte pattern!") >((complement nil?) (re-matches #".*(\.[0-9a-zA-Z]+)" line)) > (println "

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Wardrop
Haha, I was just trying out traditional formatting with clojure and had left it that way without noticing. As for the lazy thing, I should have known that as it wasn't long ago I was ready about laziness in the book I'm reading. Wrapping (dorun) around the (for) loop has fixed it. Could someone n

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Kevin Downey
for is lazy, and your code formatting is horrible. On Tue, Feb 2, 2010 at 2:48 PM, Wardrop wrote: > I've noticed that the output of a script, is often different to the > output of the same commands if run on the REPL. This makes sense, but > here's a situation which has got me a little confused.

REPL vs Script + Regex Problem!

2010-02-02 Thread Wardrop
I've noticed that the output of a script, is often different to the output of the same commands if run on the REPL. This makes sense, but here's a situation which has got me a little confused. I'm trying to run this code as a script... (use '[clojure.contrib.duck-streams]) (for [line (line-seq (r