fork download
  1. ;; add expects 2 arguments. Its arity is 2.
  2. (defn add [x y] (+ x y))
  3.  
  4. (println (add 2 2))
  5.  
  6. ;; + itself is a function, and it can have any number of arguments.
  7. (+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16) ;; and so on...
  8.  
  9. ;; foo has variable arity.
  10. (defn foo
  11. ([] ; if this function gets no arguments...
  12. (println "Lisa needs braces!")) ; do this.
  13. ([arg1] ; if this function gets 1 argument...
  14. (println "Dental plan!"))) ; do this instead!
  15.  
  16. (println (foo))
  17.  
  18. (println (foo "this is a placeholder argument."))
Success #stdin #stdout 1.67s 336576KB
stdin
Standard input is empty
stdout
4
Lisa needs braces!
nil
Dental plan!
nil