Re: Newbie question

2016-09-04 Thread Charlie
Thanx Colin & James - got it now - Charlie

On Sunday, September 4, 2016 at 5:31:40 PM UTC-4, Colin Yates wrote:
>
> 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...@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 0))
>   ([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 clo...@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+u...@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+u...@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.


Re: Frustrations so far

2016-09-04 Thread Didier
*1) Slow startup speed.*

Everyone dislikes the slow startup speed. Though it's been argued that it 
should be known as the Clojure slow startup speed. Since even though the 
JVM is slower to start then say python, most of the slowness comes from the 
Clojure overhead.

*I know this problem is being addressed by the Clojure supporters, but its 
a hard one to solve, all I can say is that its improved version after 
version.*

*2) Slow dependency resolution*

It doesn't sound like an issue with Clojure. Can you elaborate? Are you 
complaining about Leiningen being slow, or just that having to download 
dependencies is slow? Either way, this is probably more of a JVM issue, or 
even a tooling issue, you could look into alternate tooling.

*Not a Clojure related problem.*

*3) `empty?` doesn't behave as I intuitively interpret the name of it*

One thing you should embrace in Clojure, is that part of why its so awesome 
is that you are not as restricted by the limitations of the language as 
with other languages. So if you don't like empty? throwing exceptions for 
Long and Keyword, you can re-def your own empty? which catches those and 
returns false or true (whatever behavior you want) instead.

As some people have said before, a lot of the functions have good reason to 
behave as they do, but sometimes its not as intuitive from the name or form 
people's expectations. The doc mentions: "Returns true if coll has no items 
- same as (not (seq coll)). Please use the idiom (seq x) rather than (not 
(empty? x))" I'd be curious if anyone knows what is the idea behind empty? 
and why the doc mentions to use the idiom (seq x) when there is also a 
not-empty fn in core.

As an example, I struggled with `contains?` for a while. Couldn't figure 
out why they decided to make this: `(contains? [:a :b :c] :a)` return 
false. Why they chose to make contains? check for the existence of the 
index on a vector. Then I learned that the use-case behind `contains?` is 
to verify that a call to `get` will succeed. Once I learned that I was 
like... make total sense. So I wrote myself a `contains-val?` for the 
use-case I was having and done. I'm sure there's similar reasoning for 
`empty?`

*So I'd say this is not a Clojure related problem, though maybe there's a 
little issue with the names of functions having similar names then other 
popular languages and not behaving the same way.*

*4) Maps are unordered by default*

Maps are unordered from the theory itself. Don't ever expect Maps to be 
ordered, unless its very explicitly stated. Ordered Maps have different 
time/space characteristics too, which is why Maps are unordered by default. 
This isn't anything to do with Clojure. You should try and get more 
familiar with the formal literature on common data structures, as its what 
most languages build upon.

*Not a Clojure related problem.*

*5) Reloading has some quirks*

Clojure gives you so much reloading-ability with its REPL centric 
development process, that it plays against it when it fails, we get really 
upset. Its almost like the uncanny valley of reloading. You can search for 
reloaded workflows though, some people have apparently figured out ways to 
organize your code so that everything can be reloaded without ever failing 
or having to restart the REPL.

*This problem relates to Clojure, but also to Lisp in general, and I don't 
think its solvable without constraining the language too much.*

*6) Cryptic official doc*

I thought the official doc was very cryptic at first too, but over time, I 
got used to the way its documented, and I can now figure out how to use 
almost all functions just from the official doc. So I'd say this is just a 
matter of time and experience with the nomenclature and the way its 
explained. But I agree, its not meant for people just starting off with 
Clojure. I recommend clojuredocs for a more beginner friendly doc.

*Clojure could try to add a bit of a friendlier doc to its official doc.*

On Wednesday, 20 July 2016 05:54:27 UTC-7, Peter Romfeld wrote:
>
> I really love clojure over all, it makes maintenance/collaboration of code 
> such a breeze. its easy to get new employees start to work on it even 
> without any previous clojure knowledge!
>
> I do hate the JVM startup shit, i hate how you it takes forever to fetch 
> deps on a aws medium instance (you probably can fix it with uberjars)
> Im frustrated with `empty?` throwing exceptions for Long and Keyword
> Not complete clojure, but i hate datomic.api/log since you cant put into 
> your tests with a in-mem db
> I had some issues understanding that maps of certain size are not in order 
> anymore because of the underlying java functions and optimizations 
> Im a bit upset about development reload with defrecords
> most of the things that are not documented by the community are documented 
> very cryptic and hard to understand
> the api docs are almost useless! - to get the arrity and stuff.. wtf i 
> still have no clue how to use 

Re: Newbie question

2016-09-04 Thread Colin Yates
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.


Re: Newbie question

2016-09-04 Thread James Reeves
Functions in Clojure can behave differently depending on the number of
arguments they receive (their "arity"). A function can be written:

(defn foo [x]
  (str "foo" x))

But you can also write:

(defn foo
  ([] "empty foo")
  ([x] (str "foo" x))

This will do different things depending on the number of arguments:

(foo)
=> "empty foo"
(foo "bar")
=> "foobar"

- James

On 4 September 2016 at 21:54, 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 0))
>   ([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.


Newbie question

2016-09-04 Thread Charlie
I'm going through the Do Things: A Clojure Crash Course, and the following 
example (in REPL) is presented:

(defn recursive-printer
  ([]
 (recursive-printer 0))
  ([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.