This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (32)
- # asami (11)
- # babashka (5)
- # babashka-sci-dev (4)
- # beginners (65)
- # biff (11)
- # calva (35)
- # clerk (2)
- # clj-kondo (8)
- # clj-on-windows (4)
- # clojars (4)
- # clojure (122)
- # clojure-canada (1)
- # clojure-europe (31)
- # clojure-italy (6)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-spec (3)
- # clojure-uk (2)
- # clojurescript (3)
- # core-async (7)
- # core-logic (1)
- # data-science (13)
- # datalog (3)
- # datavis (3)
- # datomic (15)
- # deps-new (4)
- # emacs (34)
- # figwheel-main (1)
- # fulcro (1)
- # funcool (1)
- # holy-lambda (1)
- # lsp (41)
- # malli (21)
- # membrane (5)
- # midje (1)
- # off-topic (5)
- # polylith (3)
- # proletarian (6)
- # re-frame (6)
- # reitit (6)
- # remote-jobs (4)
- # sci (1)
- # shadow-cljs (96)
- # sql (31)
- # testing (23)
- # xtdb (49)
I’m trying to create a function that will generate a collection of collections from an input collection.
What i’m trying to do is turn this input:
'(10 20 11 30) into all the possible combinations of
(range 1 n) with
(range 'prev range nr')
so output would be:
(coll) <- index index
(10 20) <- 0 1
(10 11) <- 0 2
(20 11) <- 1 2
(10 30) <- 0 3
(20 30) <- 1 3
(11 30) <- 2 3
(clojure.math.combinatorics/combinations '(10 20 11 30) 2) => ((10 20) (10 11) (10 30) (20 11) (20 30) (11 30))
I looked into using that, but seemed a bit overkill & i need them in the specific order
also, when I add another number to the mix, it also needs to generate that in the correct order
(defn comb2 [coll] (for [x (range 1 (count coll)) y (range 0 x)] [(nth coll y) (nth coll x)])) (comb2 [10 20 11 30]) => ([10 20] [10 11] [20 11] [10 30] [20 30] [11 30]) (comb2 '(10 20 11 30)) => ([10 20] [10 11] [20 11] [10 30] [20 30] [11 30])
wauw! thank you! I got stuck on the
[(coll y) (coll x)] part where i tried to do
(nth coll y)
coll is a vector, it will work- you need
nth for lists/ sequences.
Which VS Code plugin would you recommend for just reading/editing edn files? It's for non-Clojurians, so my first thought is that Calva might be overkill but I'd consider it if there are no lightweight alternatives. Would you recommend https://marketplace.visualstudio.com/items?itemName=clptn.code-paredit?
I'd probably go with Calva, so you get syntax-aware highlighting, formatting etc. Then at least if any of these folks get curious about Clojure, they can explore it via the built-in Getting Started without needing any other setup.
Installing that standalone Paredit could lead to conflicts later...
Right, that's a good point, thank you both. Alright, they installed Calva but they still have an issue, I'll follow-up at #calva
As far as I know Calva is the only extension with any real active maintenance (plus frequent useful updates:man_dancing:).
if you are interested in paredit, which can be very rewarding to work with, emacs or spacemacs are editors where it has strong support, for decades. it's possible there are other editors with decent implementations. I find it almost impossible to use editors that don't support such a feature, though the learning curve is a bit high.
@U0LAJQLQ1 Perhaps not a great choice for "non-Clojurians" who are using VS Code, based on the OP's question 🙂
For the record. Calva has pretty decent Paredit. Not to the level of Cursive's, but still, pretty decent. Yes, I'm biased, but anyway.
Even though I love emacs, I was specifically asking for VSCode plugins, as my colleagues are already using it and I'm not (yet 😛) trying to evangelize emacs or Clojure to them. Thanks for the recommendations though 🙂
I didn't know that calva has paredit. I would recommend trying to learn a few common paredit keybindings for your most common issues. for me, paredit has been the most important thing I have learned from my experience with clojure, and I use it on any language that can support the features (js, html, css, elixir, etc...)
Calva’s Paredit is sort of Clojure only. It can handle other LISPs as well, but sadly not outside that. It could be made to do it, but so far no one has put in the work needed.
there are no general purpose paredit tools in vs code? that's too bad. it is very hard to learn, though.
Calva also has very helpful animated docs for learning its Paredit commands. https://calva.io/paredit/
> Calva’s Paredit is sort of Clojure only Not sure what you mean by that: I use paredit key bindings when editing EDN files in Calva and that works.
> there are no general purpose paredit tools in vs code? Not that I know of. I think most people will come to Paredit from the LISP direction. Most Emacs users will encounter LISP at some points when configuring their editor. For VS Code users, not so much. Unless we can change that with #C03DPCLCV9N. > it is very hard to learn, though. I might have forgotten, but I don't recall it as particularly hard. I was very motivated, though. And I had colleagues who were eager to teach me.
paredit removes character based code editing, backspace doesn't work in many contexts, you can't just cut and paste at will. you are forced to work with your code at a higher level concept, which is also completely invisible (editor doesn't show you the nodes). I'm surprised that anyone would find this easy. it took me years to get used to it and figure out what paredit concepts I needed to learn to solve all my code editing needs (calva docs help a lot with this). I found myself constantly getting stuck in paredit and switching to text mode to do quick fixes and then go back to paredit mode
Interesting. I never get stuck in Paredit... Calva Paredit strict mode only prevents deleting balanced brackets. Maybe it differs there from how Emacs paredit works?
I started using paredit 15 years ago, the docs and jargon were fairly confusing. docs had double the features of what is in calva, but you only need to know 5 or so features to do all work efficiently, it's just not obvious which ones are needed. I feel like if you aren't getting stuck in paredit, you know the features very well, or it's not very strict
But Calva Paredit doesn't behave like you describe. It's there, balanced or unbalanced brackets. It will not always work well with an unbalanced file, but as soon as you get the balance back things are dandy.
I talk to a lot of Calva users, often. There are all sorts of problems. Calva still has too many rough edges. But Paredit seldom comes up as something they need help with.
The only thing Paredit forces on you is the balanced brackets. Everything else is strictly opt-in, learn at your own pace. (And at least in Calva, I'm pretty sure you can even turn that off.) You can just use arrow keys, copy-pasta, and backspace with no problems. Or you can start picking up a few Paredit commands here and there, gradually accelerating your productivity by reducing keystrokes. (A stark contrast to Parinfer, which is its own special domain-specific language, that magically changes out from underneath you into <choose-your-lisp-dialect> as you type.) @U0LAJQLQ1 Maybe you just let yourself get overwhelmed by all the options available to you? not realizing that it's perfectly okay to just ignore everything initially?
And since the discussion seems to have firmly planted on "Paredit vs Parinfer", I think I might as well add the point that most of us probably spend way more time editing code than we do writing code. The productivity gains of Paredit are primarily earned during editing, while the gains of Parinfer are primarily restricted to the smaller percent of time spent writing fresh code.
In any case. I think we might have struck a pretty good balance with Calva's Paredit strictness. It's not really in the way much. And when it is, pressing
alt while deleting let's you bypass the strictness.
> Parinfer wasn't even mentioned before you brought it up, was it? 😃 Oh, whoops. Threads window collapsed previous messages, and I got it confused with another thread that did.
Sometimes I wish Slack had the ability to automatically close a thread to new replies after a day or two :rolling_on_the_floor_laughing:
TIL: I can press
alt-delete to erase parens without paredit preventing me!
Yup, I was today years old when I learned that (from @U0ETXRFEW just now!)
@U04V70XH6 the only difference between strict and non-strict (aka Cave Man) is that in strict mode
backspace/delete protects bracket balance, and
alt let's VS Code's default do its work, and in non-strict
alt+backspace/delete protects instead and without
alt VS Code defaults are used.
While at it. From the docs:
> There is also a setting,
calva.paredit.strictPreventUnmatchedClosingBracket, that will help you to not enter unbalanced closing brackets into the code.
when i talk about paredit, it's in emacs context (that's all i'm familiar with). you can copy and paste in it, but if you paste unbalanced parens, you are screwed and have to undo, or get out of paredit mode and fix things. it's pretty strict, but also doesn't disabled other emacs things that let you break your code, which is why it's common to get stuck. i found the upsides to be very beneficial compared to the downsides, and it seems like calva has made it so there are a lot less downsides, which sounds good. parinfer is a pretty cool idea, but whenever i use it i get completely confused, but that's just because i'm not used to indenting code anymore. @U04V70XH6 does slack let you mute threads?
But I run without that extra strict thing, since when I fat finger in an unmatched closing bracket,
backspace just deletes i.
> does slack let you mute threads? I can turn off notifications for replies to any given thread -- but I meant my comment more in the sense of preventing drive-by comments restarting threads that had already been answered and were "done" days ago.
@U04V70XH6 you want some threads to be treated like stack exchange Q/As. i think that would be a neat feature. i assume that groups like this are using slack in a way that isn't really intended, though i'm not sure how slack is intended to be used.
Zulip lets you mark threads as "solved" (or something similar) which is something I'd like in Slack. And, yeah, the Q&A sites tend to have that -- as does http://ask.clojure.org -- and so do some of the forums, such as http://clojureverse.org -- which I think all serve different purposes and different audiences. I've hoped, many, many times over the past few years, that this community would migrate to Zulip so we wouldn't be locked into a corporate system (and rely on the generosity of Slack Inc specifically for the Pro plan we're on) but lots of folks like Slack enough to stay, despite it being aimed squarely at the corporate market for employees to collaborate. (and this is way O/T for this thread and this channel but I'm happy to take this part of the discussion over to #C0CB40N8K if you want to follow-up on it)
On desktop/browser, Slack has "Completed" as the first button on hover of any message. But seems to do nothing more than add a ✅ emoji Reaction whichever message was hovered.
@U90R0EPHA That's just default react-emojis -- and it adjusts the list depending on what you most commonly respond to messages with. For me it's:
> That's just default react-emojis > Yeah. I said that. I was lamenting the fact it is such a useless proxy for feature you crave. > and it adjusts the list depending on what you most commonly > 🙀 I want that! Seems broken on my account. The bright green check box, that I never use, is always first.
@U90R0EPHA It's a preference and off by default I believe:
can someone help me understand the relationship between reducers (https://clojure.org/reference/reducers) and transducers (https://clojure.org/reference/transducers)? I came across transducers before reducers , not sure why. the examples on those pages seem similar, and they seem to have similar uses? but they might just be my naivete
great thread, thank you @U01RL1YV4P7
i guess in theory they can be used together, but they seem to be used that way