Hi,

you're right that drop-last is more general than butlast. So why does
butlast exist at all?
I would say, that it is there for a very good reasons. It solves a
common problem, namely to drop the last element of a sequence and
reads better in this case than the equivalent idiom using drop-last.
Thus, it is a perfect example for a useful abstraction and capturing
common abstractions should be the main reason for defining functions
(macros) in the first place. Obviously, any function (macro) could
always be replaced by its definition, so it has to justify its
existence by being reusable and improving readability. This also
applies if it only captures a very special use case as long as it is
common enough. I would say that butlast is well justified according to
these criteria.

Best,

    Nils

On Nov 22, 12:54 pm, Daniel Janus <[email protected]> wrote:
> Hi,
>
> Why keep both butlast and drop-last in clojure.core? The latter has the
> advantage that it's lazy and can drop off more than one element from the
> end of a seq. In contrast, I can't think of any advantage of butlast,
> except that it seems to be slightly (ca 20%) faster than (doall (drop-last
> x)). Wrapping drop-last in a doall should not be normally necessary, though.
>
> Should butlast be deprecated?
>
> Thanks,
> Daniel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to