On Thu, Feb 19, 2009 at 4:28 PM, linh <nguyenlinh.m...@gmail.com> wrote:
>
> hi,
> how can i do this in clojure?
>
> # ruby code
> def foo(x, y)
>  x + y
> end

(defn foo [x y] (+ x y))

> def bar
>  [1, 2]
> end

(def bar [1 2])

> foo(*bar) # this is fine, the result will be 3

(apply foo bar)

> foo(bar) # this is not ok, will raise exception

(foo bar) ; won't work since foo requires two arguments and only one
is being passed

> bar returns an array of size 2, but foo expects 2 parameters not an
> array.

-- 
R. Mark Volkmann
Object Computing, Inc.

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

Reply via email to