The multi-if was a typo it should be iif. I know if I am passing in a even
pairs :then 'dosomething :else 'dosomethingelse works fine with {:keys}.
What I think I should be doing is somehow grab whats in :then/:else and
wrap in a (do). At this point I was just wondering how to solve for this
maybe by parsing what's in each bucket by using :then/:else as delimiters.
Don
On Thursday, May 8, 2014 11:56:20 PM UTC-5, Atamert Ölçgen wrote:
>
>
>
>
> On Fri, May 9, 2014 at 5:44 AM, Don Hill <[email protected]<javascript:>
> > wrote:
>
>> I am trying to get a couple of edge cases to past and since I am very new
>> to clojure/lisp (2 days total) I thought I would ask.
>>
>>
>> I am using defmacro like the following. I have 2 edge case which are
>> failing. I would like to be able to process these cases where there are
>> extra bits and as you probably guessed the last 2 entries have keys with
>> not value. I don't thinks the :keys will work for these cases.
>>
>> Any ideas on how I could destruct this so all the cases would pass?
>>
>> (defmacro iif [expr & {:keys [then, else]}]
>> `(if ~expr ~then ~else))
>>
>> (println(iif (> 3 1))) ;nil
>> (println(iif (> 3 1) :then 'ok)) ;ok
>> (println(iif (< 5 3) :else 'ok)) ;ok
>> (println(iif (> 3 1) :else 'oops)) ;nil
>>
>> (println(iif (> 3 1) :else 'oops :then 'ok));ok
>> ;;(println(iif (> 3 1) :then )) ;nil
>>
>
> Why do you want to support odd number of params after `expr`?
>
> How would you expect this to work:
>
> (iif expr :then :else) -> ???
>
>
>
>> ;;(println(iif (> 3 1) :else 'oops :then (println'hi) 'ok)) ;;hi ok
>>
>
> I don't know what the implementation of multi-if looks like but the odd
> number of args after expr doesn't seem right to me.
>
> One last question; why are the branching code named/as a map? Why not
> (defmacro iif [expr then else]) which is equal to if or course?
>
> (if (> 3 1) nil nil) -> nil
> (if (< 5 3) nil 'ok) -> 'ok
>
> ...and so on.
>
>
>
>
>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to [email protected]<javascript:>
>> 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] <javascript:>
>> 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 [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Kind Regards,
> Atamert Ölçgen
>
> -+-
> --+
> +++
>
> www.muhuk.com
>
--
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
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.