> Flattening nothing gives something? "Nothing" was minding the gap until you put it inside flatten's sequence interface at which point you got a flattened sequence full of nil. Prior to that there was *not* an empty list waiting for nil. Returning nothing when in fact you expect a list (even one full of nil) is equally contradictory
> Please. A little civility, OK? I feel your pain. I apologize if you read my post otherwise. As you suggest - flatten's behavior is not entirely clear. Pointing out the docs was not meant as an act of crassness. They are however the only source of codified design rationale. > Sorry, Mon Key, but I have to agree with Randall here. Is it not ok to have free will around here? :) While it may be reasonable to expect (flatten nil) to return nil, as written and as documented in the working context - flatten doesn't appear to this mon_key as a Clojure bug. > This has nothing to do with Java interoperation. NOTHING? :=) Ok - now that Mr. Sierra has weighed in and resolved the problem... I have a question? Aside from the obvious, and apropos my understanding that the former unbuggy flatten behavior has since been decreed to be buggy, what are the mon_keys missing here? user> (def x '(1 2 3)) =>#'user/x user> x =>(1 2 3) user> (instance? clojure.lang.Sequential x) =>true user> (instance? clojure.lang.Sequential nil) =>false user> (instance? clojure.lang.Sequential '(nil)) =>true user> (instance? clojure.lang.Sequential 'nil) =>false user> x =>(1 2 3) user> (seq? x) =>true user> (seq? nil) =>false s_P On Dec 15, 2:45 pm, Lennart Staflin <lstaf...@gmail.com> wrote: > How about adding a rest around tree-seq: > > (defn flatten > "Takes any nested combination of sequential things (lists, vectors, > etc.) and returns their contents as a single, flat sequence." > [x] > (let [s? #(instance? clojure.lang.Sequential %)] > (filter (complement s?) (rest (tree-seq s? seq x))))) --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---