Hi All,

I'm fairly new to Clojure (enjoying it very much!) and had a couple 
questions regarding lazy sequences.  

1. With a sequence of sequences, I want to reduce the sequences down into a 
single sequence.  So, the heads of all the sequences gets reduced, then the 
next items, etc.  The end result would also be a lazy sequence.  Right now 
I have this code that is working, but I wasn't sure if there's some other 
way that might be clearer:

(defn amix
  ([] [])
  ([& a]
     (let [len (count a)]
       (if (= len 1)
         (first a)
         (map #(reduce + %) (partition len (apply interleave a)))))))


2. I'm planning to have a number of sequence transforming functions.  Most 
will probably have this shape:

(defn some-func [arg1 arg2 xs]
  (map #(some code...) xs))

This would be so I could consume a lazy sequence xs, operate on it, then 
output a lazy sequence.  I thought I might write a macro to simplify this 
and have the function do its own lazy-seq and recursive call to itself, 
rather than go through map (figured it might save some call overhead, and 
simplify the macro writing, but am still a bit new with this).  I imagine 
this should work fine, but is this kind of thing already encapsulated 
somewhere?

Thanks!
steven

-- 
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to