Clojure supports functions with multiple arities (http://clojure.org/
functional_programming).
Assuming you don't actually care if you call the function with a
vector, you can do something like this:
(defn sum
([] 0)
([acc & r]
(if (nil? r)
acc
(recur (+ acc (first r)) (rest r)))))
Not sure if that is precisely what you want or not.
On Jan 23, 9:58 am, wubbie <[email protected]> wrote:
> Thanks Jason.
> Anyway I'd like to have (sum) returns 0 so I used [& more].
> Is there any way to specify 0 or more args?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---