Quick question... how do you pronounce the ? at the end of a predicate?
Question mark
intonation? 🙂
The same as Âż, just upside down.
Jokes aside, if precision is needed, then for e.g. isa? it would be "is, a, question mark".
If you're just discussing something with no need for utter precision, then just "is, a".
That opens up how do you pronounce isa... my lazy annunciation would make one word of it "issuh".
I've heard some people say huh ... but I think when spoken it's unusual to need disambiguation
Does anyone say p (not really wanting to spell that one out) from LISP habit?
I watched a lecture where professor insisted it’s a long time lisp tradition to say huh?
In a decade of Clojure, I don't think I have ever heard anyone say it. :)
i like saying huh
Huh?
I tend to do:
(let [is-dog? (dog? dog)]
...)
So I think I say "is dog". When I want to be specific I refer to the predicate result. Or "dog? pred" when I refer to the predicate dog? function. And just "dog" for dog.For lazy sequences, which one is faster? (drop-while (comp not some? #{x}) some-sequence) or (drop-while (comp not (partial = x)) some-sequence)?
Impossible to tell because, looking at this code, you don't know what hash computations and equality checks will actually be doing. All depends on the actual data.
But also, it's something you should not really care about. If you use lazy sequences, this part of code is unlikely to be inside some bottleneck. If it is, it should probably be of a different shape entirely.
I would worry much more about the usage of comp here. There's just no need for it, same with partial. I'd write the predicate as #(not= % x).
I see, thanks for the answer! (also ty for the style tip I did not know of not=)
Oh, one more thing - those different forms behave differently. The second one can handle x being nil.
ah right, noted ty!
(With the usual caveats that you can never be quite sure what you've learned from it) a very convenient tool for timing this kind of Clojure thing yourself is Criterium. Just remember to put a (doall...) around any lazy-sequence work!!
i've just ran a couple of benchmarks with criterium, very cool stuff ty!
turns out the difference in negligible
Hi, eveyone! Having done some ruby and rails, I got quite fond of rails' ORM. Just started a web project in Clojure and have found writing quite a lot of basic select/insert/delete sql for every entity in db over and over again. Feeling an urge to abstract it away somehow. What is the Clojure way though?
Not an ORM but a Clojure alternative to raw SQL https://cljdoc.org/d/com.github.seancorfield/honeysql/2.7.1310/doc/getting-started
that I am using for sure
next.jdbc provides a namespace with basic CRUD operations https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.3.1048/api/next.jdbc.sql so you can avoid SQL for simple stuff.
Just what I need, thank you!
I like https://github.com/camsaul/toucan2. In most cases, I just define a model and use Toucan functions as the “repository layer.” The documentation isn’t complete yet, so sometimes you have to look into the source code. But it saves a lot of time and lets you manage many things — column transformations, before/after hooks, multiple databases, and more.
This is one is nice. Thank you!