On Sat, Jul 24, 2010 at 9:07 AM, Gary Fredericks
<fredericksg...@gmail.com> wrote:
> (defn remove-first
>   [syb lst]
>   (let [[before after]
>           (loop [b [] a lst]
>             (if (empty? lst)
>               [b a]
>               (if (= syb (first a))
>                 [b (rest a)]
>                 (recur (cons (first a) b) (rest a)))))]
>    (concat (reverse before) after)))
>
> user=> (remove-first 4 '(1 5 3 4 2 6 674 4 2))
> (1 5 3 2 6 674 4 2)
>
> I'm interested if somebody comes up with something more efficient, i.e. that
> doesn't require the reversal.

If you change (cons (first a) b) to (conj b (first a), then no
reversal will be required.

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