This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-09
Channels
- # aws (1)
- # babashka (61)
- # bangalore-clj (5)
- # beginners (83)
- # biff (2)
- # calva (4)
- # cider (6)
- # clara (5)
- # clj-kondo (72)
- # cljs-dev (31)
- # cljsrn (28)
- # clojure (8)
- # clojure-australia (1)
- # clojure-europe (19)
- # clojure-france (1)
- # clojure-losangeles (21)
- # clojure-nl (2)
- # clojure-spec (2)
- # clojure-uk (9)
- # clojurescript (13)
- # clojureverse-ops (5)
- # code-reviews (1)
- # conjure (7)
- # cursive (4)
- # datascript (2)
- # datomic (8)
- # depstar (1)
- # emacs (3)
- # etaoin (1)
- # events (3)
- # exercism (7)
- # fulcro (6)
- # girouette (2)
- # graalvm (125)
- # honeysql (19)
- # integrant (1)
- # jobs (12)
- # lsp (1)
- # numerical-computing (1)
- # off-topic (23)
- # portal (12)
- # practicalli (1)
- # re-frame (35)
- # reitit (5)
- # releases (1)
- # remote-jobs (1)
- # shadow-cljs (51)
- # tools-deps (14)
- # vim (3)
- # xtdb (20)
How to search in clojurians slack archive? I only saw archiveed channels list. But there is no search input box.
There are many ways to get help from Clojure community. I find searching in Zulip the most effective way to look at conversations, including an archive of Slack channels. For example, this query will search the beginners channel for searchphrase
stream:slack-archive topic:beginners searchphrase
https://practical.li/blog/posts/cloure-community-getting-help/Type site:
into your search engine.
e.g., https://www.bing.com/search?q=site%3Aclojurians-log.clojureverse.org+stardiviner
☝️:skin-tone-2: @stardiviner -- or you could go to the Clojurians Zulip (requires an account) and that has a nice, built-in search.
I see. thanks @seancorfield
FWIW, I don't think the search engine approach is very good via site:
since it doesn't have recent conversations. I always use Zulip since it's pretty much real-time.
Indeed, I tried sometimes now. Only few of results come out. Using Zulip searching now. 😄
hi community, greetings from argentina, i want to learn clojure, can give me some ideas where can i find a free course of this language
I'm assuming you already know how to program in some other language, and have some experience writing programs (several hundred lines of code at least). I would suggest tackling this progressively in 3 stages: 1. Minimal key concepts: Take one or two days to work through a hands-on tutorial that introduces you to the most important features, concepts, and mindset. Try to get past things that confuse newcomers to the language. Many tutorials are available at the link I've posted below. Personally, I really like Aphyr's https://aphyr.com/posts/301-clojure-from-the-ground-up-welcome, for this purpose. (And I'm obviously biased, but I also like https://github.com/inclojure-org/clojure-by-example that I helped create and teach :)) 2. Full language feature set + tooling + practical usage: A more comprehensive study (2 - 4 weeks) of the details of the various features of the language, guided by a book. Try to understand how to use the standard library of the language, and also become totally comfortable with a development workflow, language tooling (editor features, linter, REPL, build tool etc.), and get a sense of the library ecosystem. Which book to choose depends on your learning preference and budget. 3. Larger problem-solving and application-building: Follow along expert Clojure programmers as they make apps or solve a variety of problems using Clojure. There are many streams on Twitch and YouTube these days. Also of course, make your own things! Silly projects, fun projects, serious projects; whatever works! Potentially also paid tutorials or workshops, if you want to invest in building a career. Ref: Resources listed at the official website to choose from, for use in each of the stages: https://clojure.org/community/resources#_tutorials_and_learning_materials
I learned Clojure from the book Programming Clojure by Stuart Halloway and I got on well with that. There's a third edition of the book out (with two more authors in Alex Miller and Aaron Bedra). I've only read the first few chapters of the third edition but I like what I've read so far.
@uriidc A lot of people seem to do well with the free, online version of Clojure for the Brave and True.
I started with Clojure for the Brave and True (good example of presentation making content enjoyable). Like Cora said http://practical.li/ has good resources, I generally use it for how-to(s). If you are new to programming in general, try out its development environment setup, so that you can focus on Clojure first. There is http://www.clojurekoans.com (or use http://clojurescriptkoans.com/ online). There's https://purelyfunctional.tv by Eric Normand that, someone recommended. I haven't tried the course yet but his blog was very helpful. Pick any you want (or all? 😄). Welcome to life of Clojure.
hmm, I've been ambivalent about whether to buy or not this particular course. I'll give it a try now
Yeah, there used to be a $49/month price tier which I think was very affordable -- and I was a subscriber (through my company) for many months -- but the new pricing structure is a bit tough for hobbyist beginners 😞
@U029PC2K1HV I think there's still a subscription option, but you see it after you create and account, log in and go to your profile. I'd email Eric at <mailto:[email protected]|[email protected]>. He's kind and responsive. Plus, knowing a beginner is getting priced out is good feedback for him.
@U017ANLQXBJ Thanks, will contact him.
I've got a question but it's rather java than clojure (but I can't seem to find an answer) When writing (lots of) data to a file when does Java trigger the system call to the file? I'd like to minimize the amount of system calls (because with "lots of" data it's an overhead I'm not happy to pay too often), so I'd like to know at most how much data I can write in a single write operation. Or should (can?) I rely on Java's internals handling this fine for me? (I've had trouble with those internals shooting me in the face so my trust in them isn't solid)
If you do not get answers here, try the https://londonjavacommunity.co.uk/ who also have a slack community
I haven’t done this level of fine tuning in years, but if you care for maximum performance, I believe one strategy is to buffer a bunch of writes for up to a period of time/max number of entries (say, ~1 ms and, say, 1000 max entries) and at the end of that short period write everything in one shot. That should improve your performance as opposed to flushing/fsync-ing on every write.
Those numbers are hypothetical, you want to fine tune for your use case: latency requirements, size of those “entries” (whatever they are) are all important to think about. And as with all things performance, exact and repeatable benchmarks are the gold standard. I recommend YourKit for the JVM (no affiliation), it’s an excellent profiler.
For inspiration in terms of achieving good writing performance to a file, perhaps this can be useful: https://github.com/Factual/durable-queue/blob/master/src/durable_queue.clj
To answer your question directly: you’ll most likely be able to achieve higher write throughput by implementing additional clever+creative buffering at the cost of higher latency and more complex implementation. You have to decide if the trade-off makes sense for your case.
The easiest place to start might be to play around with creating your own BufferedWriter (https://docs.oracle.com/javase/10/docs/api/java/io/BufferedWriter.html) rather than using the default sized one you get from
... that will let you control the flushing to the os a little more explicitly ...
I have to handle pretty large files pretty often. It doesn't matter if the individual writes are delayed as long as the whole file gets finished quick
I'm assuming you already know how to program in some other language, and have some experience writing programs (several hundred lines of code at least). I would suggest tackling this progressively in 3 stages: 1. Minimal key concepts: Take one or two days to work through a hands-on tutorial that introduces you to the most important features, concepts, and mindset. Try to get past things that confuse newcomers to the language. Many tutorials are available at the link I've posted below. Personally, I really like Aphyr's https://aphyr.com/posts/301-clojure-from-the-ground-up-welcome, for this purpose. (And I'm obviously biased, but I also like https://github.com/inclojure-org/clojure-by-example that I helped create and teach :)) 2. Full language feature set + tooling + practical usage: A more comprehensive study (2 - 4 weeks) of the details of the various features of the language, guided by a book. Try to understand how to use the standard library of the language, and also become totally comfortable with a development workflow, language tooling (editor features, linter, REPL, build tool etc.), and get a sense of the library ecosystem. Which book to choose depends on your learning preference and budget. 3. Larger problem-solving and application-building: Follow along expert Clojure programmers as they make apps or solve a variety of problems using Clojure. There are many streams on Twitch and YouTube these days. Also of course, make your own things! Silly projects, fun projects, serious projects; whatever works! Potentially also paid tutorials or workshops, if you want to invest in building a career. Ref: Resources listed at the official website to choose from, for use in each of the stages: https://clojure.org/community/resources#_tutorials_and_learning_materials
I have a problem that I'm not sure how best to solve functionally. Does anyone have any ideas? I want to filter a list to remove duplicate elements, without changing the order of the elements that I don't remove. So if X appears multiple time in the list then I want to return a resulting list which contains only the first instance of X. E.g.
(remove-duplicates '(1 2 3 4 1 5 6 2 7 8 1 9)
... returns:
(1 2 3 4 5 6 7 8 9)
I could implement it using a loop/recur, keeping a set of all the elements seen so far, but that feels a little imperative to me and I'm wondering if there's some obvious approach that I've missed.I see a couple of approaches possible. One is if your list is sorted by its content and not arbitrarily ordered, something like https://clojuredocs.org/clojure.core/sorted-set or https://clojuredocs.org/clojure.core/sorted-set-by are probably your best bet.
But for strictly what you are asking, I think https://clojuredocs.org/clojure.core/distinct keeps the order of the input ?
> but that feels a little imperative to me and I'm wondering if there's some obvious approach that I've missed.
distinct
does indeed implement it using recur
, and also can return a transducer. So, in a sense, you're thinking of re-implementing distinct
. You can simply use distinct
and get laziness for free as well. And if you explicitly don't want laziness, you can use (distinct)
the transducer.
Nice, it looks like distinct is indeed what I want. (Can't believe I missed it!) Many thanks. I'll give it a try when I get back to the computer.
just to add a point about transducers ... with transducers, lazyness is optional at the point of application. So if you write
(into [] (distinct) [1 2 3 4 1 5 6 2 7 8 1 9])
it will eagerly produce a vector, but
(sequence (distinct) [1 2 3 4 1 5 6 2 7 8 1 9])
will return a lazy-seq which filters out duplicates. I only mention this cos I'm starting to feel that transducers are distinctly better than lazy-seqs in several ways and think it's a good thing for people to learn 😉what is a good way to take a map and return a map with the same keys and transformed keys?
Sounds like a job for reduce
. Or Medley: https://weavejester.github.io/medley/medley.core.html#var-map-keys
thanks, my code now
(defn update-vals [map f]
(reduce
(fn [coll [k v]]
(assoc coll k (f v))) {} map))
(update-vals @data count)
there's also update
which takes a map and runs a function on a key to return a updated map, so
(update {:a 1} :a inc) ;; => {:a 2}
which you could use instead of (assoc coll k (f v))
if you passed in the map as the second argument to reduce, maybe like this?
(defn update-vals [m f]
(reduce #(update %1 %2 f) m (keys m)))
another way to write this would be using a transducer like this:
(defn update-vals [m f]
(into {} (map #(update % 1 f)) m))
however, this comes up so often, that apparently a core implementation is coming soon : https://ask.clojure.org/index.php/1926/adding-functions-map-vals-and-map-keysYou could also
(defn update-vals [coll f]
(into {} (map (fn [[k v]] [k (f v)])) coll))
or
(defn update-vals [coll f]
(reduce-kv #(assoc %1 %2 (f %3)) {} coll))
This might help: https://lambdaisland.com/blog/2019-12-04-advent-of-parens-4-a-useful-idiom
why is this code not return :equal when I compare two empty list
(ns sublist)
(defn classify [list1 list2]
(cond (= list1 list2) :equal )
((clojure.set/subset? list1 list2) :sublist)
((clojure.set/subset? list2 list1) :superlist))
Also a heads up: The clojure.set
functions generally expects to be passed sets as arguments, not lists. This is often a point of confusion, because sometimes they seem to work with lists, even though that is just an accident of their implementations.
oke, so I have to convert them to sets or write some own code to check if a list is a super or sublist
There are many ways to compare lists and other "sequential" things. If you don't care about comparing the ordering of items within the lists, you can convert them both to sets and use the clojure.set
functions
For the other direction, there is a built-in clojure.set/superset
, which you can use instead of swapping the arguments, to make the intent in your code even clearer
Quickly checking https://exercism.org/tracks/clojure/exercises/sublist, it seems that it does.
I feel stupid asking this, but is there a function in core that is the complement to not-any?
? Because any?
just sends back true
.
you could always cast it to a boolean after with
(boolean (some #{9} [1 2 3]))
I would use some ... tbh ... and not worry about casting it ...I think that any?
was added for clojure.spec
to have a predicate that always returned true, so it would allow all values when checking data.
in that case though, wouldn't you write
(some false? [1 2 false 4])
?? ... cos it's using the set as a predicate that's making the false value a problem???sure, the strategy has a strong dependency on the data
@U02DEQJ409F Have you tried (complement not-any?)
But wouldn't that read the whole input when I want to fail fast and inversely ?
((complement not-any) #(not (= 7 %)) [1 2 3 4 5]) => must read the whole coll before saying nothing is equal to 7, then take the complement
(fantasy-any? #(not (= 7 %)) [1 2 3 4 5]) => fails on 1
Just personally, if it might have to read every element i don't mind it always reading every element
I am filtering a list, and need to dynamically assemble some filters based on a map (e.g. {:favorite true :active false :has-foo true}) .. whats a good way to do that? Each filter value has a predicate associated.