Fork me on GitHub

I'm trying to create a structure such that (for [x (repeat 100) y (range 100)] [x y]) effectively "pinning" the x at 100 while the y goes from 0 - 100 such that [100 0] [100 1] [100 2] ... But this doesn't work for me and just makes my laptop very hot 😂


That's not going to do what you want. Try (for [x (range 3) y (range 3)] (str "X is " x " and y is " y)) and see what that gives you.


Compare that with (map (fn [x y] [x y]) (repeat 100) (range 100))


(Sorry if that's a bit cryptic -- I've been bashing code all day and my brain is full of parentheses...)


@bones what do you think of (for [y (range 100)] [100 y])?


Hahah thanks @lilactown, so simple - I'm not sure why I was reaching for x and y to both be sequences!

👍 8

Im sure there was a reason but this will suffice for now. Cheers :thumbsup:

Michael Fiano06:10:10

What is the recommended OpenJDK version to use with Clojure 1.9.0?

Michael Fiano06:10:02

Also hello again. I'm coming back to Clojure after a 6 month break and realized that I'm getting a load of errors with JDK 10.


I believe you should get good results with OpenJDK 8 for Clojure itself, assuming you have no libraries you want to use that have problems with it.


That is a fairly conservative answer, I know, but if you don't mind other people finding and debugging issues that might exist with newer JDK versions for a while, you can take advantage of their efforts later.


Hello, I shared in the clojurescript channel, but I didn’t get answer. Maybe that was the wrong channel. I would like to understand better how works the :npm-deps, works well or not. I don’t understand fully. Eg. I can integrate semantic-ui-react and quill.. i have feeling something I did in a wrong way.


That was the ns implementation.


So, If somebody could help me understand better this, how works well .. how to add any kind of npm lib to clojurescript projects... I don’t understand fully what is the wrong.


or that is a “bad” idea now use npm-deps in clojurescript projects?


Hi @sb! npm-deps feature is experimental and you most probably don’t want to use it. However there’s an alternative build-tool called shadow-cljs that can deal with dependencies from npm. It’s also possible to use webpack to bundle your npm-dependencies and include them in your cljs build using foreign-libs.


hi @sb I'm not sure if i can really help you with the current setup but would recommend to try shadow-cljs for npm integration


shadow-cljs is probably the most developer friendly solution atm, Different approaches are described in more detail here.


@valtteri @jacek.schae thanks, thanks, shadow-cljs is working on node just?


it's npm package


Thanks for the help!! 👍


@sb no problem! And just to clarify: shadow-cljs build tool itself is npm package but shadow-cljs builds can target node or browser.


Yes, i bought a course about and I understand how to use shadow-cljs. @valtteri thanks!

Nathaniel Stevens14:10:52

Could anyone point me towards a good article or example of how to organize a Clojure app?


@nathaniel.scott.steve good is subjective, but I recently published a small ring app: should be fairly easy to follow for beginners


if you have any specific questions, shoot


for larger projects, it’s usually recommended to manage things like database connections, caches, etc. with Component, Integrant, etc.


you can also take a look at Luminus which builds a Clojure app from scratch

Nathaniel Stevens14:10:46

Thank you @borkdude, that’s very helpful!

Surya Bhamidipati16:10:36

Can you please recommend a best video tutorial/ PDF to learn and implement apps using clojure? Our team is basic/intermediate in java knowledge .. and our goal is to implement framework in clojure to deal with Kafka in couple of months. At present we are ramping up in Kafka.


@suryabh If you like video tutorials, I'd highly recommend Eric Normand's PurelyFunctional TV:


(some you'll have to pay for)


also, I don't know your specifics at all (of course), but my general observation is that people learn Clojure with an immediate goal of making a framework usually learn a lot about Clojure but rarely end up with code they want to continue using once they know Clojure


(my Clojure learning experience was working on a web framework that didn't really go anywhere - I did end up sticking with Clojure though)

Surya Bhamidipati17:10:41

@seancorfield Thank you very much for your help.


@suryabh I would highly recommend reading Joy of Clojure for a whirlwind tour of the ideas behind Clojure (Rich Hickey and Stuart Halloways talks if you prefer videos), and Clojure Programming for details about the language while solving problems on


Building a prototype of an appropriately scoped project in your organization is valuable too.

Surya Bhamidipati17:10:29

@noisesmith Yes, I was recommended to use to clojure to develop framework for Kafka type applications, But I found lot of applications developed ( including web apps ) using clojure, that's really awesome.


There are a lot of libraries that are very good at specific things, and it's much easier to wire them together to make an application than in other language ecosystems (that I've encountered) resulting in not many frameworks being present in the Clojure ecosystem. À la carte is the first thing that comes to my mind when I think about the Clojure ecosystem. Simple Made Easy is a must watch.

👍 4

Hello. (set coll) accepts a collection, but (sorted-set &keys) and (sorted-set-by comparator &keys) take vararg items. I accept, but: Can you see any reason for not making them more uniform?


the equivalent of (set coll) would be (hash-set x1 x2 x3) I picture set and hash-set as being the set equivalents as vec/vector for vectors.


uniformity would make the first argument ambiguous


"did you mean to put the first item in a set, or is it already a set?"


a set within a set is totally legit


and if you want to cast a collection into a sorted-set or sorted-set-by then you'd use into

(into (sorted-set) coll)
(into (sorted-set-by comparator) coll)


As a Java neophyte, where can I learn what happens behind lein uberjar(Java classpath, Maven build process, etc) and how tools.deps is better (if it is)?


short answer is tools.deps doesn't do jar building at all, you'd need to pick up some other tool that does that


neither lein nor tools.deps uses maven for building - they do use maven compatible classpath resolution


Sorry @noisesmith, I should have phrased the question a bit better. @alexmiller said something about dependency declarations being lies and maven relies on semantic versioning to determine which artifacts to use (in his Dependency Heaven talk). How does a tools.deps based approach mitigate this?


Oh, I thought lein uses maven


this isn't a difference in packaging, tools.deps doesn't do packaging, it's a difference in dep resolution


lein, boot, and tools.deps use the maven infrastructure some of the maven libraries internally, but none of them use maven itself


Regarding what @alexmiller means by that, I'd trust him to give a better answer than I could muster. The only other thing I'd add here is that the goal of an uberjar packaging step is to bake a specific set of deps into a standalone pre-resolved compisite artifact.

👍 4
Alex Miller (Clojure team)19:10:32

Maven also uses the Maven libraries internally

Alex Miller (Clojure team)19:10:36

Maven/lein/boot/tools.deps select a set of transitive dependencies based on your set of initial root deps

Alex Miller (Clojure team)19:10:10

In the case where different versions of a lib are specified in different branches of the transitive dependency tree, the dependency resolution algorithm will pick one of that set to include. The “lies” aspect is that the combined set of versions chosen can easily be different than any set of versions you’ve ever tested with yourself.

Alex Miller (Clojure team)19:10:40

tools.deps doesn’t really change that, but it uses a different dependency resolution algorithm than the one used by mvn/lein/boot (one that favors new versions rather than the first version found). semver is actually not really a factor in either of them explicitly.


> uniformity would make the first argument ambiguous @ghadi Couldn't you say the same about (set coll)?


@trailcapital, Yes, I know how to use them. I was curious why the signatures of set and sorted-set differ. Thank you.


so i inadvertently created a function with the same name as a core function and the repl gave me a nice warning that i did so. How do I back that out so that I get the core function back?


@chase-lambert You can still access the core function as clojure.core/the-fn (whatever the-fn it was you overwrote).


so you can do (def the-fn clojure.core/the-fn) to reinstate it to the current namespace in the REPL


ahh! something about that fix pleases me. hahaha. thanks!


@chase-lambert just as an addendum, you can also do any of the following: (refer 'clojure.core :only '[the-fn]) (refer-clojure :only '[the-fn]) (refer 'clojure.core) (refer-clojure) the latter two will bind the names for the entirety of clojure.core for you. doing a (clojure.core/refer-clojure) after an (in-ns 'foo) is often handy


Hello guys, happy to be here and find an active community about Clojure


Willing to find help and provide help too!


i've been trying to figure out clojure data types and structures, but everywhere i've looked seems a little different, so i wanted to ask here


Is this correct? and if it is, where Records go? are Records (seq?) too? oh btw, i've forgot to add Sets inside sequences


@cybersapiens97 The REPL to the rescue:

user=> (defrecord Foo [a])
user=> (coll? (Foo. 1))
user=> (seq? (Foo. 1))
user=> (seqable? (Foo. 1))
user=> (map? (Foo. 1))


So records are seqable, they are maps, they are collections. They are not ISeq but they can yield sequences:

user=> (seq (Foo. 1))
([:a 1])


So, what i'm observing is that some collection are not sequences, but some of their functions yields sequences, so you can process the items inside


i was thinking that all collections are sequences under the hood, and they were just a different implementation of a sequence...


because all collections share the fundamental functions such as first, rest (i've learned FP by manipulating arbitrarily large data only with lists and the respective functions first rest and cons, then creating abstractions such as Map Reduce and so on)


Researching a bit more, sequences seems to be an 'interface' (maybe one from Java?) that all Collections types implements


alright, i understand now


it's possible to manipulate any collection by using seq functions, because they are all conformed with the lSeq interface...


see also seqable?

user=> (doc seqable?)
  Return true if the seq function is supported for x


which has some surprising aspects (eg. String is seqable?)


i think one of the reasons why clojure abstractions can cope with any collection is because of lSeq interface am i right?


seq function can turn thing that are not seq? into seq 's. // N.B. canSeq must be kept in sync with this!


canSeq is the source of seqable?


A slight correction. it's possible to manipulate things not just because they directly implement ISeq, they may be able to be transformed into something that implements ISeq, hence seqable?. A string is such an example. It does not implement ISeq. (seq "ab") returns a clojure.lang.StringSeq which implements ISeq.

Eric Ervin23:10:45

Reading this last thread, I'm thinking about 2 approaches to presenting Clojure data structures. Some presentations feed you each data structure as they think you need to know it, maybe starting with lists or vectors. Others (at least one I've read) present the properties of data structures and tell you which data structures fit into those properties.