Try this.

(defn my-filter [pred? coll]
  (loop [c coll
         ret (empty c)]
    (if-let [x (first c)]
      (if (pred? x)
        (recur (rest c) (lazy-cat ret [x]))
        (recur (rest c) ret))
      ret)))


24.10.2013, 23:58, "Wilson" <tortugac...@gmail.com>:

>  I am supposed to make my own filter function without using "remove". I have 
> this made, but it is not working like it should be working. I don't have any 
> idea what is wrong with it. Please help me out. For example, if I give the 
> function the parameters odd? and [1 2 3 4]. It only returns (1), but it 
> should obviously return (1 3). I don't know why it works like that.
>
>  (defn my-filter [pred? a-seq]
>    (if (empty? a-seq)
>      a-seq
>      (if (pred? (first a-seq))
>        (cons (first a-seq)
>              (my-filter (rest a-seq) '())))))
>
>  --
>  --
>  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/groups/opt_out.

-- 
-- 
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/groups/opt_out.

Reply via email to