Re: Applying "and" macro to sequence

2010-02-20 Thread ataggart
On Feb 20, 8:38 am, Johnny Kwan wrote: > The specific problem I'm trying to solve is to see if two sequences of > strings "=" each other.  If one sequence is shorter, the "=" comparison stops > at the end of the shorter sequence.  So I've been trying to do a simple > (reduce and (map = seq1 seq

Re: Applying "and" macro to sequence

2010-02-20 Thread ataggart
On Feb 20, 8:38 am, Johnny Kwan wrote: > Hi, > > This is a very basic question, but I can't find the answer anywhere.  How do > you take the "and" or "or" of sequence?   Try using every? and some, respectively. -- You received this message because you are subscribed to the Google Groups "Clo

Re: Applying "and" macro to sequence

2010-02-20 Thread Meikel Brandmeyer
And while we are at it: (defn f-or [s] (loop [s (seq s)] (when s (if-let [f (first s)] f (recur (next s)) On Sat, Feb 20, 2010 at 06:24:53PM +0100, Meikel Brandmeyer wrote: > (defn fand > [s] > (loop [s (seq s) > l nil] > (if s > (when-let

Re: Applying "and" macro to sequence

2010-02-20 Thread Meikel Brandmeyer
Hi, here a "short-circuiting" (in sense of realising only needed values from the passed seq) version of a "function and". (defn fand [s] (let [s (seq s) l nil] (if s (when-let [f (first s)] (recur (next s) f)) l))) clojureql.sql=> (fand (map = [:a :b :c] [:a :

Re: Applying "and" macro to sequence

2010-02-20 Thread Johnny Kwan
OK, I should have just tried passing in 'and at the REPL before posting. Of course, it works. Is this the idiomatic way? I'm still curious about short-circuiting. On Feb 20, 2010, at 11:38 AM, Johnny Kwan wrote: > Hi, > > This is a very basic question, but I can't find the answer anywhere.

Applying "and" macro to sequence

2010-02-20 Thread Johnny Kwan
Hi, This is a very basic question, but I can't find the answer anywhere. How do you take the "and" or "or" of sequence? They are defined as macros and can't be passed into "apply" or "reduce". Is there some reader macro character to force it? Also, how does one write it so that it will shor