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 (map rest seqs)))))))
> 
> I didn't checked for nil but for empty? on purpose, nil might also be a value 
> in a list - I know it's will not be common but a list that has '(nil 1 2 3) 
> would become '(<default> 1 2 3) if checking for nil and not empty.

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 any other collection at that point in the iteration. The second point where 
nil shows up is fnil. first returns nil when it gets passed nil. We have to 
modify it to return the default in that case. However the passed nil is again 
from the seq itself not the  contents. So contained nils are not a problem at 
all.

user=> (extend-tupel :x [1 nil 3] [4 5 6 7])
((1 4) (nil 5) (3 6) (:x 7))

Note, there were some missing brackets in my code. I corrected the above quote.

Sincerely
Meikel

-- 
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

Reply via email to