>
> How different was what you came up with from this?
>
> (def else? (constantly true))
>
> (defmacro condval [vname & body]
>   `(cond
>      ~@(interleave (map (fn [p] `(~p ~vname)) (take-nth 2 body))
>                    (take-nth 2 (rest body)))))
>
> Just out of curiosity. :)
>

I just naively adapted the cond macro:

(defmacro condval
  [target & clauses]
    (when clauses
      `(if (~(first clauses) ~target)
            ~(if (next clauses)
                (second clauses)
                (error "condval requires an even number of forms"))
            (my-stuff.utils/condval ~target ~@(next (next clauses))))))


(defn else? [_] true)

Learned a lot from your version though, thanks!  I'm still yet to memorize 
all the useful combinators in the library.

 

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