This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-15
Channels
- # babashka (13)
- # beginners (37)
- # calva (19)
- # cider (15)
- # clj-kondo (2)
- # clojure (152)
- # clojure-norway (1)
- # clojure-sweden (10)
- # clr (5)
- # emacs (19)
- # honeysql (1)
- # introduce-yourself (19)
- # joyride (1)
- # lsp (4)
- # malli (5)
- # membrane (6)
- # off-topic (11)
- # pathom (18)
- # polylith (13)
- # practicalli (3)
- # releases (4)
- # shadow-cljs (38)
I found this snippet in a library - is the doc string accurate here? It looks like this eager-or
uses normal or
under the hood, which is not eager, so is this actually eager?
(defn eager-or
"A version of `or` that always evaluates all its arguments first"
([] nil)
([x] x)
([x y] (or x y))
([x y z] (or x y z))
([x y z & rest]
(reduce #(or %1 %2) (or x y z) rest)))
phew!
maybe the [x y z & rest]
case should use eager-or
too then
or no, its using an anon function which would also evaluate arguments eh
lol thanks!
so I confess I am trying to understand myself, but I feel confident that the author of this library knows more than I do, which is which I am studying it... in this library looks like its used to sort of propagate events to child components
so not so much as a way to make a choice
its from humbleui in case youre curious https://github.com/HumbleUI/HumbleUI/blob/main/src/io/github/humbleui/core.clj
its cool stuff! there isnt a built in dropdown component yet so I've been trying to make my own frankenstein version with the available code
i'm working on a wavetable synthesizer (as of today) and was figuring out what frontend i wanted it to have
oh awesome... yeah I started playing with humble bc I wanted to avoid JS... let me know if find something you like better!
I took a glance at some of the code using this function and concluded it would be easier to grock if they just used let
with or
.
(let [case1 (foo)
case2 (bar)]
(or case1 case2))
That clearly separates the branching-return logic from the declaration that everything must be calculated; and avoids requiring a custom control-flow function with somewhat surprising behavior.@U04HK53G7SQ what are you using to generate sounds?
apart from the fft stuff, which could easily be rewritten, it's all platform-agnostic. i'm still torn about whether to have it be a react app or not
Hello, I was struggling with java interop in Clojure. I wanted to convert this java example from https://github.com/chocoteam/choco-solver (Overview)
I just managed to figure it out. But I would like to ask, how am I suppose to sensibly know that I should use things like into-array
to convert the type etc.
Are there any good, extensive and recommended java interop resources I should study to gain a better grasp of this? (Especially for someone like myself who has not ventured deeply into Java before; and instead started with Clojure right off the bat)
My uncleaned code atm:
(def model (Model. "my first problem"))
(def ^IntVar x (-> model
(.intVar "X" 0 5)))
(def ^IntVar y (-> model
(.intVar "Y" 0 5)))
;; (.post (.element model x (int-array [5 0 4 1 3 2]) y))
(.post (.lt (.add x y) 5))
(-> model
.getSolver
(.setSearch (into-array
^"[Lorg.chocosolver.solver.search.strategy.strategy.AbstractStrategy"
[(Search/inputOrderLBSearch (into-array
^"[Lorg.chocosolver.solver.variables.IntVar;"
[x y]))])))
(.solve (.getSolver model))
(.printStatistics (.getSolver model))
I don't know about your broader question, but you can just (into-array AbstractStrategy [...])
and (into-array IntVar [x y])
it looks like you're trying to type-hint the vector as a primitive array, using a string, which isn't going to do anything
varargs is a particularly gnarly area of interop, unfortunately. I hope it is fixed in a coming version of Clojure.
Yeap the official docs doesn't really help me whenever I'm stuck with stuff like this
related: https://clojure.atlassian.net/browse/CLJ-2631 I used the typed-array macro proposed when I encountered this issue edit: I misread, I though you had reflection issues. But I'll leave the comment because you may encounter some soon 😉