This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-26
Channels
- # announcements (3)
- # babashka (23)
- # beginners (54)
- # calva (9)
- # cider (8)
- # clj-kondo (18)
- # cljsrn (25)
- # clojure (69)
- # clojure-australia (1)
- # clojure-europe (7)
- # clojure-spec (13)
- # clojure-uk (1)
- # clojurescript (122)
- # conjure (8)
- # cursive (15)
- # defnpodcast (9)
- # deps-new (2)
- # emacs (22)
- # fulcro (10)
- # graalvm (36)
- # luminus (5)
- # meander (5)
- # minimallist (1)
- # observability (6)
- # off-topic (54)
- # reagent (8)
- # reitit (2)
- # releases (1)
- # reveal (25)
- # shadow-cljs (21)
- # tools-deps (50)
- # vrac (1)
- # xtdb (2)
It’s https://notion.so. I’ve been using it for notes, todos, and docs since 2016 but recently discovered Zettelkatsen and created a database in Notion for it. It’s working quite well!
(map inc [1 2 3])
;; => [2 3 4]
(map #(update % 1 inc) {:a 1 :b 2 :c 3})
;; => ([:a 2] [:b 3] [:c 4])
Could that be considered an example of Clojure’s polymorphism or is there a different term for it?
that’s kind of polymorphic, in that different data structures implement seq
in different ways
map entries are also vectors, so you can get
assoc
or update
by index (like you just did)
But usually when people talk about Clojure’s polymorphism, they’re talking about the user-level facilities: protocols and multimethods
Not quite. For that ability to operate on vectors, hash-maps, sets, strings with the same collection functions if I remember right.
It's all about abstractions.
Am I wrong or — since update-in
does not take the target map as the last argument, I cannot use it in a threaded expression?
@vincenz.chianese It might sound dumb, but you can maybe improve your code by having named functions broken out
(defn increment-score-for [game-state player]
(update-in game-state [player :score] inc))
Hi! Would you choose Leiningen or cli-tools for a new project and why? Does anyone use clj-tools on Windows?
Definitely the latter. It's much more simple and much more composable. deps.edn
is also just an EDN map, whereas project.clj
is not - a tool cannot simply parse it without using Leiningen code.
Leiningen works great and gets the job done, try both and go with the one that makes the most sense to you
I'm eager to try cli-tools but current Windows implementation requires to change Powershell script security settings which I don't want to (maybe because I don't know nothing about it)
@UEQDV142J I have two Windows machines that I do Clojure work on -- but I use WSL2 (and Ubuntu) and linuxbrew (the Linux version of Mac's brew/homebrew package manager) so I install/update the Clojure CLI via brew on both Windows machines (in Linux) and on my Mac as well.
A lot of tutorials still feature Leiningen, so there's no harm in having both Leiningen and the Clojure CLI on your system.
Also, if you want to use Powershell but don't want to deal with the security stuff, you could install Scoop (a Windows package manager) and then install the Clojure CLI -- and various other useful Windows tools like Babashka and clj-kondo -- using Scoop.
See the bottom section of https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows
Also, if you have any questions about the CLI tools on Windows, or you get stuck, there's a #clj-on-windows channel.
Oh, I thought it used some local installation like brew
to circumvent that? Good to know.
Ah, gotcha!
@UEQDV142J If the Powershell security setting is absolutely a dealbreaker, here is a port of the Clojure CLI that is just 1 binary which you can place anywhere on your path: https://github.com/borkdude/deps.clj
(it's been a while, I don't remember having to change that, but I guess that's less worrisome than needing to do it for some random .ps1
script off the Internet 🙂 )
@U04V70XH6 if you enable all the developer experience settings in windows 10 I think it changes that setting as well.
There’s also a -Scope Process
option that only applies to the current session that may work for the install, but I suspect scoop relies on it being set persistently since I think it also uses ps scripts for its packages.
If you're new (like me) I'd suggest going with lein. Just use it, and start writing clojure/business code. You can forget about it until you hit a roadblock and then re-evaluate.
@U04V15CAJ Can speak to that in detail since he just set up Docker/VS Code/Calva and gave a great talk at WSL Conf recently about it.
I've only used Docker from WSL2, not from Powershell / cmd.exe. Personally I don't run Clojure in docker, but all the other stuff like Postgres etc. VSCode has great support for connecting to remote machines or Docker containers, so you can run your entire dev env in a Docker container if you want.
Yeah, my setup is Docker via WSL2 (and I actually run Atom via WSL2 as well but I know VS Code has a great "remote" option to run on Windows but talk to code etc on WSL).
That too. In WSL2 it's just a matter of installing the command line script and then typing code
, and tadaa, it works.
@UEQDV142J I would read this: https://code.visualstudio.com/docs/remote/containers#:~:text=The%20Visual%20Studio%20Code%20Remote,Studio%20Code's%20full%20feature%20set.
Is there standard function in clojure that lets you create the cartesian product of functions? I.e. some function X such that ((X f1 f2) x y) = ((f1 x) (f2 y))?
I don't know of a standard function that does exactly that, but you could accomplish something similar with
(map (fn [f v] (f v)) [f1 f2] [x y])
@U0DUNNKT2 no, the point, if understand it correctly, is to apply (f1 x)
to (f2 y)
Ah, it was unclear to me if that return was supposed to be a list or a function invocation
And it's not really a Cartesian product either way. That would be [[(f1 x) (f1 y)] [(f2 x) (f2 y)]]
or something like that. The juxt
function could help with that, maybe.
On the other hand, Wikipedia says https://en.wikipedia.org/wiki/Cartesian_product#Cartesian_product_of_functions
Huh, so "Cartesian product of functions" != "Cartesian product of collections of functions and arguments". TIL
(defn X [f1 f2]
(fn [x y]
[(f1 x) (f2 y)]))
Yes, exactly this. I was just wondering if that exists out of the box. Juxt is similar, but it applies all functions to the same argument rather than creating a n-ary function.