This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # 100-days-of-code (2)
- # announcements (3)
- # beginners (95)
- # bitcoin (1)
- # cider (18)
- # cljdoc (9)
- # cljs-dev (8)
- # clojure (55)
- # clojure-austin (1)
- # clojure-berlin (4)
- # clojure-italy (21)
- # clojure-nl (1)
- # clojure-russia (2)
- # clojure-spec (47)
- # clojure-uk (31)
- # clojurescript (19)
- # component (8)
- # cursive (5)
- # data-science (2)
- # datomic (33)
- # emacs (7)
- # events (1)
- # figwheel (8)
- # fulcro (16)
- # graphql (27)
- # hyperfiddle (5)
- # jobs (1)
- # jobs-discuss (85)
- # keechma (7)
- # luminus (11)
- # mount (6)
- # off-topic (23)
- # onyx (1)
- # re-frame (4)
- # shadow-cljs (29)
- # specter (19)
- # tools-deps (11)
- # uncomplicate (3)
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.
(Sorry if that's a bit cryptic -- I've been bashing code all day and my brain is full of parentheses...)
Hahah thanks @lilactown, so simple - I'm not sure why I was reaching for x and y to both be sequences!
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.
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.
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
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. https://gist.github.com/jmlsf/f41b46c43a31224f46a41b361356f04d
@sb no problem! And just to clarify:
shadow-cljs build tool itself is npm package but shadow-cljs builds can target node or browser.
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: https://github.com/borkdude/who-follows-me should be fairly easy to follow for beginners
for larger projects, it’s usually recommended to manage things like database connections, caches, etc. with Component, Integrant, etc.
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: https://purelyfunctional.tv/
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)
@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 http://4clojure.com
Building a prototype of an appropriately scoped project in your organization is valuable too.
@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.
(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.
and if you want to cast a collection into a sorted-set or sorted-set-by then you'd use
(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 https://github.com/clojure/tools.deps.alpha/wiki/Tools
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?
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.
Maven/lein/boot/tools.deps select a set of transitive dependencies based on your set of initial root deps
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.
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
@trailcapital, Yes, I know how to use them. I was curious why the signatures of
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
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
@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])
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
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.Foo user=> (coll? (Foo. 1)) true user=> (seq? (Foo. 1)) false user=> (seqable? (Foo. 1)) true user=> (map? (Foo. 1)) true
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
From the sources:
seq? is implemented by
(instance? clojure.lang.ISeq x)
clojure.lang.ISeq is a interface
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?) ------------------------- clojure.core/seqable? ([x]) Return true if the seq function is supported for x
i think one of the reasons why clojure abstractions can cope with any collection is because of lSeq interface am i right?
Again from sources (attention to comment) https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L534
seq function can turn thing that are not
// N.B. canSeq must be kept in sync with this!
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
seqable?. A string is such an example. It does not implement
(seq "ab") returns a
clojure.lang.StringSeq which implements
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.