Here's my take: (defn remove-first [x coll] (let [[pre post] (split-with #(not= x %) coll)] (concat (pre (rest post))))
On Jul 24, 11:41 am, nickikt <nick...@gmail.com> wrote: > Hallo all, > > I'm working trough Essentials of Programming Languages. I'm trying to > right a function like this one: > > (defn scheme-remove-first [syb lst] > (if (empty? lst) > '() > (if (= (first lst) syb) > (rest lst) > (cons (first lst) (scheme-remove-first syb (rest lst)))))) > > in a idiomatic clojure way (this is just a scheme to clojure 1:1 > version). I don't like that this function produces stack overflows. > > I tried some stuff but I it (almost) semantically correct working but > I didn't like my code. Can anyone come up with a good version? -- 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