This form allows the fn to have multiple arities. So if I call (recursive-
printer) it will 'invoke' ([] (recursive-printer 0)). If I call (recursive-
printer 1) then it will 'invoke' ([iteration] ...).

HTH

--
  Colin Yates
  colin.ya...@gmail.com



On Sun, 4 Sep 2016, at 09:54 PM, Charlie wrote:
> I'm going through the Do Things: A Clojure Crash Course, and the
> following example (in REPL) is presented:
>
> (defn recursive-printer  ([]  (recursive-printer ))  ([iteration]
> (println iteration)  (if (> iteration 3)  (println "Goodbye!")  (recursive-
> printer (inc iteration))))) (recursive-printer) ; => Iteration 0 ; =>
> Iteration 1 ; => Iteration 2 ; => Iteration 3 ; => Iteration 4 ; =>
> Goodbye!
>
> This works as expected, but I don't understand the syntax of the
> function definition. Specifically: (defn recursive-printer ([] (recursive-
> printer 0)). Isn't the parameter list supposed to be a vector []
> not ([]...)? Also, I don't see how [iteration] is resolved on the
> next line.
>
> Thanx for any help!
>
>
> --
>  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.

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