Roelof Wobben <rwob...@hotmail.com> writes:

> The only thing which is failing now is this one ; 
>
> (defn abs [x]
>   (< x 0)
>     (* x -1);
>     x)
>
> I keep getting -2 as answer where it must be 2 

Well, the function contains three forms where the results of the first
two are ignored and only the value of the last one is returned.  So here
you need an `if`.

  (defn abs [x]
    (if (< x 0)
      (* x -1)
      x))

Bye,
Tassilo

BTW: Why do you have those semicolons in your code?  That ends a
statement in C-like languages but in Lisps including Clojure it starts a
comment spanning till the end of the line.

-- 
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/d/optout.

Reply via email to