This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (3)
- # babashka (36)
- # beginners (77)
- # boot (3)
- # chlorine-clover (10)
- # cider (27)
- # clj-kondo (1)
- # cljs-dev (4)
- # clojure (256)
- # clojure-belgium (1)
- # clojure-europe (9)
- # clojure-uk (18)
- # clojuredesign-podcast (9)
- # clojurescript (54)
- # cryogen (8)
- # cursive (3)
- # data-science (1)
- # datomic (2)
- # duct (31)
- # events (1)
- # exercism (3)
- # fulcro (116)
- # joker (20)
- # kaocha (5)
- # meander (2)
- # nrepl (4)
- # off-topic (10)
- # other-languages (15)
- # re-frame (18)
- # reagent (4)
- # shadow-cljs (44)
- # sql (14)
- # tools-deps (17)
Anyone have an easy way to get the namespace of a .cljs file? All I have is a string representation of the file contents. Or is my best shot to just resort to regex?
@kevin.van.rooijen something like https://github.com/clojure/tools.namespace/blob/8d632bfcd8ce4f872f9a9cdafb5245c9b10574a0/src/main/clojure/clojure/tools/namespace.clj#L57-L94 is probably most reliabel
hey, reading abit SICP and curious about streams and their impl in clojure as with LISP. what are streams in clojure then? I'm assuming
'seq' can be thought as a 'stream-like'? with it laziness? how can I think on streams with clojure? I see that
delay, force are used as-well.
In Clojure, a seq is anything that implements the
*clojure*.lang.Seqable interface (https://clojure.org/reference/sequences#_the_seq_interface), which means it supports
next , if lazy) and
cons (so stuff can be added to the seq). This means you can consume a "stream" / seq in a loop (recursively if you like) by iteratively processing the
first item, and consuming the
When I hear streams I think of core.async: https://github.com/clojure/core.async But I haven’t read SICP that far in, so I may be off in suggesting that
> Our implementation of streams will be based on a special form called delay. Evaluating (delay ⟨exp⟩) does not evaluate the expression ⟨exp⟩, but rather returns a so-called delayed object, which we can think of as a “promise” to evaluate ⟨exp⟩ at some future time. As a companion to delay, there is a procedure called force that takes a delayed object as argument and performs the evaluation—in effect, forcing the delay to fulfill its promise. good memory
The thing delay creates in scheme is a promise, which is like a clojure delay and not like a clojure promise
I might be trying to much to create pure functions, possibly in places where it's hard to do so. To the more experienced Clojurians out there, is it normal that your DB layer functions are quite impure?
I need to do some bitwise operations in Clojure; is there a way to work with 16-bit unsigned integers instead of the default 32-bit signed integers?
If your app is basically doing CRUD, it's OK to have impure functions all over the place. It's worth trying to separate out any transformation as pure functions tho'.
(let [data (read-stuff db) new-data (pure-transform data)] (write-it db new-data))
(that way you can test the transformation logic independently, perhaps generatively, for example)
yeah exactly. My business logic will be a lot of transformation, I had it in my head I'd be using (-> for these
I hope it's not rude, but since my question got covered up by the previous discussion, I'm going to repost it. > I need to do some bitwise operations in Clojure; is there a way to work with 16-bit unsigned integers instead of the default 32-bit signed integers?
Hello, I know less than John Snow, haven't written anything yet, but a quick search:
(->> 123 (bit-and-not 16rFFFF))
I think they dealt with a problem like this on this episode of Apropos: https://www.youtube.com/watch?v=parkWOdl8RU
user=> (bit-and 5 \a) Execution error (IllegalArgumentException) at user/eval1 (REPL:1). bit operation not supported for: class java.lang.Character user=> (bit-and 5 (int \a)) 1
> Java defines several bitwise operators, which can be applied to the integer types, long, int, short, char, and byte
@didibus I think it's sort of a niche case, working with bitwise stuff, so it's probably not the best use of time for the Clojure developers.
Although it would be interesting to have a library that allows manipulation of this kind of stuff.
Clojure/JVM enables semi-straightforward use of values with types that are Java primitive
double . I am not aware of any ways to make that semi-straightforward for other Java primitive types like