If the function is called with one argument, what Clojure language rule allows x to appear outside the vector brackets?
On Jul 10, 7:18 pm, Jonathan Fischer Friberg <odysso...@gmail.com> wrote: > There's no interfaces, that's the function definition. > > define function max > (defn max > > attach docstring > "Returns the greatest of the nums." > > attach metadata > {:added "1.0"} > > if max is called with one argument, use this function definition > ([x] x) > > if max is called with two arguments, use this function definition > ([x y] (if (> x y) x y)) > > if max is called with more than two arguments, use this function definition > ([x y & more] > (reduce max (max x y) more))) > ___________ > > As you can see, y is introduced in one of the functions definitions. > Also > see:http://clojure.org/special_forms#Special%20Forms--(fn%20name?%20[params*%20]%20exprs*)<http://clojure.org/special_forms#Special%20Forms--%28fn%20name?%20[params*%20]%20exprs*%29> > andhttp://clojure.org/metadata > > Jonathan > > On Sun, Jul 10, 2011 at 11:44 PM, octopusgrabbus > <octopusgrab...@gmail.com>wrote: > > > For Question 1 this is an example of multiple interfaces. Got it. > > > On Jul 10, 5:42 pm, octopusgrabbus <octopusgrab...@gmail.com> wrote: > > > From Clojure api for max > > > > (defn max > > > "Returns the greatest of the nums." > > > {:added "1.0"} > > > ([x] x) > > > ([x y] (if (> x y) x y)) > > > ([x y & more] > > > (reduce max (max x y) more))) > > > > Question 1: Why can y be introduced as a local binding without a let? > > > > Question 2: What is the map {:added "1.0"} doing? > > > > Thanks. > > > cmn > > > -- > > 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 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