Fork me on GitHub

You can test out libraries with lein try easily but is there a way to test a version a clojure not within a project? I’m guessing download and run the jar but I’m curious if people do that.


@lambeta Your expression returns a lazy sequence without realizing it. When the later elements are realized outside of the binding established by with-open, the stream will be closed.


@lambeta If you want to realize the sequence, use doall inside of the with-open


@hans I wanna know why the later elements will be realized outside with-open?


@lambeta That entirely depends on what you do with the return value of the with-open expression. For example, the repl might want to print it or parts of it.


a lazy-seq is just a java object with a pointer to an anonymous fn


I just use repl to eval with-open expr, you know, in emacs with ctrl-x e


the scope of with-open, on the other hand, ends when the form is evaluated


this leaves you with a lazy-seq that has not been realized yet but whose underlying stream is closed


the cider middleware realizes the lazy-seq when it tries to pretty-print the results


but that happens to be after execution has left the scope of with-open


does that make sense?


@pesterhazy does it mean (do (take 2 …)) could not realize all lazy sequences, but doall or dorun could?


neither do nor take realize the sequence.


take takes as many elements as indicated by the argument, and the good thing about it is that it only does that without realizing the full sequence.


(do (foo)) is exactly equivalent to (foo)


make sense


Hello everyone! For those who haven't seen this yet, Hashrocket have put out a Websocket shootout with a number of different languages, including Clojure! I'm keen to see if we can make things faster, and hope to maybe learn a thing or two from some of the more experienced Clojure-tuners I know. I've opened this PR with a few tweaks, including some GC tuning (as mentioned by the danger man himself, @alexmiller in I'd really appreciate any and all input from people with some experience making Clojure fast (correction faster). I know a few names spring to mind, but don't want to call anyone out. Volunteers only please! 😄 The PR can be found here:


The one thing I forgot to mention was Immutant. I wonder if it'd be faster than http-kit.


I have homework problem that I am struggling to wrap my mind around. I’m taking a Java bootcamp at The Iron Yard and we are studying Clojure in parallel (sort of). This particular assignment was withdrawn because too many people were having trouble with it. But the Java version of the assignment was almost too easy so I wanted to tackle the Clojure version. I’ve posted a question to StackOverFlow here: And my code is on GitHub: The problem I have is trying to take in an array of string values and return a hashmap index where the keys are the first letter of a word and the value associated with each key is an array of strings beginning with that letter. [“aardvark” “people” “apple” “zipper” “pepper”] should produce: { 😛 [“people” “pepper"], :a [“aardvark” “apple”], :z [“zipper”]} This was my first attempt:


I welcome any pointers. One person on Stackoverflow recommended that I could achieve the desired result in one line using reduce, but have yet to puzzle out how.


You don’t need to redo the word-list in the let.


Also, you have to string things together.


The update-in isn’t assigned to anything so the work it does is lost. Same with the assoc.


Everything in Clojure is immutable so changes to index have to be assigned to something.


And yeah, this is definitely something I’d do in a reduce but that can be daunting for someone new to Clojure. You might want to try to work it out in a loop/`recur` and then translate it into a reduce.


Another tip, you don’t need to solve everything in a single function. Anytime a function starts to get gnarly (i.e., multiple, complex calculations within a function), break it out into other functions.


For example, the function in your update-in, I’d put it into its own function and call it from within the update-in.


Hope this helps.


Thanks @akiva I’ll look at it again tonight!


@cptully: reduce the starting seq by taking each word, taking its first character, converting it to keyword, and conjing the word to the existing value in the map bound to the keyword. the special case is each new keyword, when the value is nil, but that is easily solvable by (get result :a []). i could have written this paragraph as an oneliner, but that is not the point :)

Shantanu Kumar20:09:06

Can anyone suggest a way to describe a boolean option in tools.cli that I can specify as true or false? E.g., --include (true) vs --no-include (false)


you're asking for a different name than "include"?

Shantanu Kumar21:09:20

I’m just looking for a way to describe a boolean option that I can specify as true or false on the CLI

Shantanu Kumar21:09:52

Don’t want two flags really

Shantanu Kumar21:09:21

Boolean options with nil or false default work fine, but I’m struggling to override a true default via CLI


@blueberry I am trying to parse through your paragraph…. I have come up with this: (def key-words (map keyword (map #(subs % 0 1) word-list))) => #'tiy-homework-collection-katas-clojure.core/key-words key-words => (:a :a :z :p) from this: word-list => ["aardvark" "apple" "zamboni" "phone”] I have found that a simple call to set will clean up the key-words list, but I am still at a loss for how to build the arrays for each keyword.


all functions that you need for this are: reduce, get, keyword first, and assoc. in one line. sorry, if i give you any more info, i'll spoil the learning experience.


@blueberry You are most helpful!


i forgot conj. you need conj to add a word to the list.