> > - 'you always get back a value of the concrete type you supplied for > argument X' isn't obviously less cognitively burdensome than 'you always > get back a sequence' >
Combining objects of type X should give a result that is of type X. That seems the most natural to me. > - doesn't Python, in all its teachability, just throw a TypeError if you > try and concatenate differently typed collections, even in trivial cases > (e.g. (1,) + [2])? Is there a way to do that in Python which doesn't > involve writing a concat function w/ a bunch of type checks > Whether to allow vectors and lists to combine is something that can be discussed. Seems like may be a good idea and an improvement over Python. > - runtime list construction in Clojure is comparatively rare. I'm not a > teacher, but in a practical educational setting I would focus on vectors as > the general-purpose ordered collection type - esp. if i were interested in > appending to them. > I like below. It also takes over the str command. Basically a single function to do all basic combinations. Notice whether run time list construction is a good idea or not does not have to be decided by me. I just make the ability available. (defn comb [& args] (let [comb_ (apply concat args)] (cond (string? (first args)) (apply str comb_) (vector? (first args)) (into [] comb_) (list? (first args)) comb_))) -- 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/d/optout.