This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-06
Channels
- # announcements (3)
- # aws (3)
- # babashka (9)
- # beginners (87)
- # calva (3)
- # chlorine-clover (7)
- # cider (6)
- # clj-kondo (1)
- # cljs-dev (31)
- # cljsrn (7)
- # clojure (26)
- # clojure-berlin (5)
- # clojure-europe (84)
- # clojure-nl (3)
- # clojure-uk (13)
- # clojurescript (39)
- # core-async (4)
- # core-logic (3)
- # cursive (3)
- # datomic (10)
- # devcards (5)
- # duct (2)
- # emacs (3)
- # events (1)
- # fulcro (6)
- # jobs (4)
- # kaocha (12)
- # london-clojurians (1)
- # off-topic (21)
- # other-languages (2)
- # pathom (5)
- # pedestal (1)
- # re-frame (1)
- # reitit (3)
- # remote-jobs (6)
- # reveal (6)
- # sci (34)
- # shadow-cljs (99)
- # tools-deps (99)
What's people's thoughts on extending nil
to support qualifications. For example, imagine you could do: nil/missing-key
or nil/file-not-found
These would all be treated as a standard nil
except there'd also be a function to get the qualified part as a keyword so you could possibly branch on it if you wanted. Also, it would print with the qualification so the programmer can understand the reason for the nil.
And I'm imagining they'd get interned, so two nil/missing-key
would be equal.
overloading null and falsey values is common mistake in other languages/systems/databases. I think using some other alternative would be more appropriate. (eg. [nil :missing-key]
over nil/missing-key
)
Also nil
is currently the underlying Java null
(and JavaScript null
I assume?) so you'd have to deal with all the conversion back and forth between a native host value and the "metadata" you wanted to attach -- which could be horrendous from a performance p.o.v.
I'm not thinking of overloading it. Nil would still be nil and behave like nil. But it provide a qualification that can let you specify what was nil.
Ya, the performance interop is interesting. But Clojure allows you extend nil with protocols, so I'm assuming it already has some facilities? But maybe won't work for something that need seperate instances of nil.
The idea for example, when you call (get map :key), now both of those return nil:
`(get {} :key)
(get {:key nil} :key)`
So for example, with qualified nils, the former could return: nil/missing-key
and the latter just nil
what you're proposing is still an aggregate value of nil
and a qualification or meta data on a nil value. clojure already has a way to describe aggregate values: vectors, sets, and maps. metadata seems like a more appropriate way to do what you're describing, but it's not available and I'm pretty sure it's for performance and due to the limitations imposed by interop with java.
Ya, meta-data would work as well. Ya, the performance implication and interop are a good point in terms of feasability for Clojure
Unless it could be handled at compile time, but I don't think it has the information, or that this feature is important enough for it
Hi guys, for past few months I have been playing with Clojure and Clojurescript. Its been really fun. Along the way I have created few packages that suits my need. Please check them out. Feedbacks are welcome. https://github.com/ludbek/sql-compose https://github.com/ludbek/validator
Is there a bridge from Clojure to Moldable Development? http://youtube.com/watch?v=Pot9GnHFOVU
Given a multimethod and its arguments, how can I obtain the result of the dispatch fn? This would be useful for logging purposes
It turns out that multimethod functions are defined in Java space have have a public dispatchFn
field. So, it looks like calling (.dispatchFn -multimethod-)
does the trick
It returns the dispatch function itself so we can invoke the dispatch fn on the args to get the dispatch value
I’m trying to implement a version of the change-making problem in Clojure with the twist that I’d like to actually have all possible change-combinations returned instead of just the number of different combinations. I found this https://stackoverflow.com/questions/41806819/find-all-combinations-of-a-given-set-of-integers-summing-up-to-a-given-sum but the Haskell and Python solutions make me feel like a terrible imposter 🙈 If anyone feels like adding a Clojure answer (or helping me come up with one) I’d be very thankful 🙂
The Python answer is probably not very Clojure-y but the Haskell answer seems like it might be somewhat translateable:
partitions 0 xs = [[]]
partitions _ [] = []
partitions n (xxs@(x:xs)) | n < 0 = []
| otherwise = (map (x:) (partitions (n-x) xxs)) ++ partitions n xs
The piece I don’t quite understand is this I think:
(map (x:) (partitions (n-x) xxs))
It means find all way to get sum (n-x) form list. And for returned list prepend x to it
ah cool, the (x:)
wasn’t quite clear to me but prepending makes sense
It is haskell version of cons sort of
(defn partitions [n [x & xs :as xxs]]
(cond
(zero? n) [()]
(empty? xxs) ()
(neg? n) ()
:else (concat (mapv #(conj % x) (partitions (- n x) xxs))
(partitions n xs)) ))
(partitions 10 [3 4 5])
Hey Clojurians. I was able to succesful speak at a meetup with a tan "Clojure 101 for Javascripters" and ea good! Ends with a video/live coding (http://egghead.io style) about building a web server with httpkit and compojure. Now I was invited to another meetup but same talk and I want to give some spin to the content. One thing I miss in the first time was a real example of using the repl (I'm new to Clojure too but less new that the audience) and now I'm thinking in a good example of repl driving development. Do you think that just continue with the server example, run the server un the repl and dinamically add a new route to it will be a good example?