Re: Local bindings w/o let

2011-07-11 Thread Michael Wood
On 11 July 2011 03:42, Luc Prefontaine wrote: > Lets try to clear the confusion a bit here: > > (def max1 [x] x) > (def max2 [x y] (if (> x y) x y)) > (def max3 ([x y & more] (reduce max (max x y) more))) > > The above a three different fns. To be even more clear, the above should be: (defn max1

Re: Local bindings w/o let

2011-07-10 Thread Ken Wesson
On Sun, Jul 10, 2011 at 5:42 PM, octopusgrabbus 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 bind

Re: Local bindings w/o let

2011-07-10 Thread Luc Prefontaine
Lets try to clear the confusion a bit here: (def max1 [x] x) (def max2 [x y] (if (> x y) x y)) (def max3 ([x y & more] (reduce max (max x y) more))) The above a three different fns. max1 has only the arg x. max2 has only x and y and max3 has x and y and maybe other arguments to select the maximu

Re: Local bindings w/o let

2011-07-10 Thread Charlie Griefer
On Sun, Jul 10, 2011 at 4:51 PM, octopusgrabbus wrote: > If the function is called with one argument, what Clojure language > rule allows x to appear outside the vector brackets? ([x] x) The x outside of the vector brackets is the value being returned. So if max is called with only a single arg

Re: Local bindings w/o let

2011-07-10 Thread octopusgrabbus
I have another question about max. Is there an advantage if this were re-written with repl? On Jul 10, 7:18 pm, Jonathan Fischer Friberg wrote: > There's no interfaces, that's the function definition. > > define function max > (defn max > > attach docstring > "Returns the greatest of the nums." >

Re: Local bindings w/o let

2011-07-10 Thread octopusgrabbus
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 wrote: > There's no interfaces, that's the function definition. > > define function max > (defn max > > attach docstring > "Returns

Re: Local bindings w/o let

2011-07-10 Thread Jonathan Fischer Friberg
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 functi

Re: Local bindings w/o let

2011-07-10 Thread Luc Prefontaine
2) Meta data, max was introduced in V1.0 On Sun, 10 Jul 2011 14:44:16 -0700 (PDT) octopusgrabbus wrote: > For Question 1 this is an example of multiple interfaces. Got it. > > On Jul 10, 5:42 pm, octopusgrabbus wrote: > > From Clojure api for max > > > > (defn max > >   "Returns the greatest o

Re: Local bindings w/o let

2011-07-10 Thread octopusgrabbus
For Question 1 this is an example of multiple interfaces. Got it. On Jul 10, 5:42 pm, octopusgrabbus 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) mor