I just wrote a fn called takeall that seems to do what I want: (defn takeall [x & [y]] (if (and x y) (take x y) x))
On Aug 20, 1:44 pm, Glen Rubin <rubing...@gmail.com> wrote: > I am writing a fn to extract elements from a sequence using optional > start and end values. I will do this by testing if 'end' or 'start' > values are passed as parameters to the function. If the user does > not specify a end value I would like the fn to return the entire > sequence from 'start' to end. Is there a way to take all. I know I > could just specify a really high number, but that seems kind of > messy. Or I am also thinking the fcn could have several branches, but > that also seems messy. I think it's best to just assign a default > value if there is none. > > The body of fn would look something like this, where 'start' and 'end' > would have number values: > (drop start (take end coll)) -- 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