This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-03
Channels
- # beginners (111)
- # boot (1)
- # braveandtrue (4)
- # calva (2)
- # cider (16)
- # clara (35)
- # cljdoc (4)
- # cljs-dev (22)
- # clojure (80)
- # clojure-dev (17)
- # clojure-europe (3)
- # clojure-italy (57)
- # clojure-japan (1)
- # clojure-nl (4)
- # clojure-serbia (1)
- # clojure-spec (25)
- # clojure-uk (108)
- # clojurescript (67)
- # cursive (17)
- # data-science (5)
- # datascript (6)
- # datomic (6)
- # devcards (1)
- # events (1)
- # expound (13)
- # figwheel (2)
- # figwheel-main (6)
- # fulcro (7)
- # jobs-discuss (8)
- # kaocha (1)
- # luminus (3)
- # nrepl (6)
- # off-topic (58)
- # re-frame (1)
- # reitit (16)
- # remote-jobs (1)
- # ring (1)
- # shadow-cljs (70)
- # spacemacs (10)
- # sql (42)
- # testing (1)
- # tools-deps (8)
- # vim (1)
lets vote what to read next joy of clojure 2nd or programming clojure 3rd ed?
I voted for JoC, assuming you haven't read earlier editions of either.
JoC 1ed was my first Clojure book (but I had Lisp/FP background). Clojure in Action 1ed was my second Clojure book.
i have java(2 years) and common lisp(3 months + PCL book), 4 months of clojure background
Back then, there weren't too many options 🙂 I loved Clojure Programming when that came out. Since then I've bought almost everything except Living Clojure and a bunch of the somewhat random Packt Publishing Clojure books (variable quality!).
You'll love JoC then!
And then maybe Clojure Applied? Or Programming Clojure 3ed.
Getting Clojure is an interesting read to.
Clojure Cookbook too, although it's getting a bit long in the tooth (maybe there's a 2ed planned/in the works?).
Oh, apparently I do have Living Clojure. It just isn't inside a folder like all my other O'Reilly books...
Several publisher auto-sync to Dropbox, so those are by publisher. That way I can read the PDFs on any device.
So I have 82 tech books by Pragmatic, O'Reilly, and Manning. And then maybe another 50 or so ebooks from other publishers.
(My OneDrive a/c has 127 PDFs but that includes technical papers, book previews, reference cards, and a variety of other non-tech-book things so it's hard to be sure)
Mostly time. I've been accruing tech books for decades.
Several publishers let you "register" your physical copy of a paper book and then you can d/l the ebook for it. But I still have a pretty massive paper library from early decades. Including classics like "A Microprogrammed Implementation of APL" and "Programming the 6502" 🙂
@seancorfield how fast do you read technical books? Like about something new.
I'm a speed reader so, very fast...
I mean it takes me few days per chapter including practice, exaples and side sources like articles on the topic.
If I'm practicing alongside, that slows me down a bit. I think I got through Seven Languages in Seven Weeks, including all the exercises in less than 30 hours total. Maybe even close to half that? Can't remember.
On average, I read about a page a minute. Seven Languages is just over 300 pages. Yeah, I must have gotten through that in a lot less than 30 hours, even with exercises 😐 It's kind of a weird "skill". I was tested in kindergarten and they figured out I have some sort of semi-eidetic memory which means I don't read linearly -- I sort of "snapshot" blocks of text etc and then my brain somehow decodes them asynchronously.
Hi all, I am hitting a weird issue with core.spec when trying to add extra assertions to a s/keys
spec using s/and
.
I have been able to make a minimal example of the problem.
(s/def ::bar (s/or :string string?
:int int?))
(s/def ::foo (s/and (s/keys :req-un [::bar])
(fn [x]
(prn x)
true)))
(s/explain ::foo {:bar "bar"})
;;=> {:bar [:string "bar"]}
;;=> Success!
(s/explain ::foo {:bar 1})
;;=> {:bar [:int 1]}
;;=> Success!
You can see that the predicate after the s/keys
spec now has the :bar
value transformed to a pair by the ::bar
s/or
spec. This is not what I expected.@sofra That's how s/or
works.
It conforms the value into a data structure that shows how it matched the spec.
thanks @seancorfield I sort of understood that, I didn’t realise it got conformed and passed the conformed value through each predicate in the s/and
.
user=> (require '[clojure.spec.alpha :as s])
nil
user=> (s/def ::bar (s/or :string string? :int int?))
:user/bar
user=> (s/conform ::bar 42)
[:int 42]
user=> (s/conform ::bar "42")
[:string "42"]
user=>
Yes, s/and
flows values through so if something conforms a value, that is what's passed on to the next predicate.
hi, i can't see how read-string can possibly execute code without using the eval. (read-string "(+ 1 1)") evals to a list (+ 1 1). "(+ 1 1)" is the user input.
@tomaas I’m not sure I fully understand the question, but “#=” is the read-eval literal and calls eval
here: https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader.clj#L588 more notes, https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader.clj#L866
@mhuebert thanks. read-string is called at runtime parse the this string and return a reader macro expresion. But arent macros expanded at compile time? I dont get how that parsed expression gets run
how many phases does the 'runtime' compile executable have then? read-time + eval-time?
maybe some of the info on this page will help https://stackoverflow.com/questions/5669933/is-clojure-compiled-or-interpreted#5670203
> the dynamic and interactive nature of Clojure that means you can invoke the compiler at run-time if you want to. This is all part of the Lisp “code is data” tradition.
One way is to use mapv
instead of map. It’s eager. Another is to use transducer version (into [] (map #(...)) coll)
last time someone asked a similar question, I think the most Clojure-y answer was to use a transducer
Heh, tried this out of curiosity and it works. You can use normal function composition.
user> (def doall-map (comp doall map))
#'user/doall-map
user> (doall-map #(or (println %) %) [1 2 3])
1
2
3
(1 2 3)
This might have some serious caveats though, I’m not sure. Personally I like the transducer version most.
Hello, I’m used to the cond
from Scheme, does the cond
in Clojure support the =>
syntax?
@duncanmak I'm not familiar enough with Scheme to know what that syntax means -- could you explain?
like, in Scheme:
(cond ((re-match ...) => (lambda (match) ...)))
if-let
feels a bit like it, but it only allow one test
Ah, take a look at condp
and see if that's closer to what you're looking for...
I found https://github.com/Engelberg/better-cond, but I don’t wanna take on a library
yeah, i was looking at condp
, but it doesn’t seem to capture the result from the test
are you sure? its result-fn, which must be a unary function, is called with the result of the predicate as its argument
BTW, it's better not to post the same question in multiple channels -- so folks in one channel don't have to spend time answering something that was already answered elsewhere.
@duncanmak Did condp
solve your needs?