Don't want to thank each of you individually - so to all who answered -
Thank-you!
On Monday, May 23, 2016 at 9:10:47 PM UTC-4, Phil Virgo wrote:
>
> I just starting to try and teach myself Clojure. Kindly let me know if
> there is a more appropriate place I should post simple questions.
>
>
>
>
>
>
> Nope, that's fine. (Although you can't nest one anonymous function inside
> another as then it would be ambiguous what % refers to.)
>
To further clarify when anonymous functions can't be nested:
#(+ % (+ % (+ % (+ % ==> totally legal
#(+ % (#(* 2 %) %)) ===> totally not legal
In
On Monday, May 23, 2016 at 8:10:47 PM UTC-5, Phil Virgo wrote:
>
> I just starting to try and teach myself Clojure. Kindly let me know if
> there is a more appropriate place I should post simple questions.
>
This is fine! You might also enjoy the #beginners room on the
http://clojurians.net/
Your use of % is syntactically correct.
However, think of what is happening in the second example.
Every time take-while invokes your function #(= (first %) %), % is bound to
an element of the list s.
So, something like this would happen when take-while is checking the first
element: (= (first
On May 23, 2016 at 6:10:46 PM, Phil Virgo (pwvi...@gmail.com) wrote:
(take-while #(= (first %) %) s) ; IllegalArgumentException Don't know how
to create ISeq from: java.lang.Long clojure.lang.RT.seqFrom (RT.java:505)
Your problem is that take-while will call the predicate for each item in
the
I just starting to try and teach myself Clojure. Kindly let me know if
there is a more appropriate place I should post simple questions.
(def s '(1 1 1 4 99)
(take-while #(= (first s) %) s) ; works fine: (1 1 1)
(take-while #(= (first %) %) s) ; IllegalArgumentException Don't know how
t