Big thanks to everyone, the suggestions given are all very welcome,
even if I didn't really needed a better version as my use of mappad is
really simple for now. It was just curiosity on my part.
The lazy version by Heinz could be quite useful in other situations,
I've added it to my toolbox.
On Dec 27, 2009, at 22:33 , Meikel Brandmeyer wrote:
Checking for nil here is independent on the contents of the lists. The `(map
seq lists)` first turns everything in lists into a seq. If a collection is
empty it will be turned into nil. This nil is independent of any contained
nil of
On Dec 26, 2009, at 21:09 , Meikel Brandmeyer wrote:
Here is a more idiomatic (and fully lazy) version using the fnil function
proposed by Rich here:
http://groups.google.com/group/clojure/msg/f251cfd9baab440a
(defn extend-tupel
[default lists]
(lazy-seq
(let [seqs (map seq
Hi,
Am 27.12.2009 um 12:22 schrieb Heinz N. Gies:
(defn extend-tupel
[default lists]
(lazy-seq
(let [seqs (map seq lists)]
(when (some identity seqs)
(cons (map (fnil first [default]) seqs) ; Note previously
missing brackets.
(apply extend-tupel default
On Dec 26, 2009, at 2:37 , Nicolas Buduroi wrote:
I'll have a look at this, it would certainly make this function more
idiomatic to Clojurians.
Thanks for the suggestion.
I've another one I like even better, it get's a bit away from mapping over n
list but it could achiev the same:
On Dec 23, 6:04 am, Nicolas Buduroi nbudu...@gmail.com wrote:
Hi, today I needed to use the map function on multiple collections
which didn't had all the same length. In this case, it returns a
sequence of the size of smallest one. But the problem I was facing was
required to map until the end
Hi,
Am 26.12.2009 um 14:45 schrieb Heinz N. Gies:
On Dec 26, 2009, at 2:37 , Nicolas Buduroi wrote:
I'll have a look at this, it would certainly make this function more
idiomatic to Clojurians.
Thanks for the suggestion.
I've another one I like even better, it get's a bit away
On Dec 23, 2009, at 6:04 , Nicolas Buduroi wrote:
Hi, today I needed to use the map function on multiple collections
which didn't had all the same length. In this case, it returns a
sequence of the size of smallest one. But the problem I was facing was
required to map until the end of the
On Dec 25, 1:52 am, Tom Hicks hickstoh...@gmail.com wrote:
A slight modification, which I think avoids counting each collection
twice:
(defn append-val [val colls]
(let [lengths (map count colls)
maxlen (apply max lengths)]
(map #(concat %1 (repeat (- maxlen %2) val)) colls
On Dec 25, 9:08 am, Heinz N. Gies he...@licenser.net wrote:
On Dec 23, 2009, at 6:04 , Nicolas Buduroi wrote:
Hi, today I needed to use the map function on multiple collections
which didn't had all the same length. In this case, it returns a
sequence of the size of smallest one. But the
A slight modification, which I think avoids counting each collection
twice:
(defn append-val [val colls]
(let [lengths (map count colls)
maxlen (apply max lengths)]
(map #(concat %1 (repeat (- maxlen %2) val)) colls lengths)
)
)
On Dec 23, 10:30 am, kyle smith
It's a little shorter if you unconditionally concat repeat.
(defn append-val [val colls]
(let [maxlen (apply max (map count colls))]
(map #(concat % (repeat (- maxlen (count %)) val)) colls)))
user (apply map + (append-val 0 [1] [2 3] [4 5 6]))
(7 8 6)
--
You received this message
On Dec 23, 12:30 pm, kyle smith the1physic...@gmail.com wrote:
It's a little shorter if you unconditionally concat repeat.
(defn append-val [val colls]
(let [maxlen (apply max (map count colls))]
(map #(concat % (repeat (- maxlen (count %)) val)) colls)))
user (apply map +
Hi, today I needed to use the map function on multiple collections
which didn't had all the same length. In this case, it returns a
sequence of the size of smallest one. But the problem I was facing was
required to map until the end of the longest, padding the smaller ones
with a default value. I
14 matches
Mail list logo