This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-29
Channels
- # aleph (1)
- # announcements (10)
- # aws (1)
- # beginners (110)
- # calva (4)
- # cider (26)
- # clj-kondo (14)
- # cljdoc (24)
- # cljsrn (16)
- # clojure (76)
- # clojure-europe (3)
- # clojure-ireland (2)
- # clojure-italy (15)
- # clojure-nl (8)
- # clojure-spec (23)
- # clojure-sweden (4)
- # clojure-uk (92)
- # clojurescript (37)
- # cursive (19)
- # datomic (59)
- # duct (1)
- # emacs (4)
- # fulcro (7)
- # graalvm (7)
- # graphql (1)
- # hoplon (69)
- # jobs (4)
- # jobs-rus (1)
- # kaocha (2)
- # leiningen (5)
- # luminus (2)
- # pathom (8)
- # reagent (6)
- # reitit (11)
- # spacemacs (12)
- # sql (3)
- # tools-deps (9)
- # unrepl (1)
- # vim (57)
I really didn't want to get out of bed today, but I was in bed reasonably early. I'm so tired still.
morning, tomorrow and Friday off due to Ascension Day. can't wait... lots of prod problems at the moment :face_vomiting:
I guess if you export anything you need to adapt it to adapt it to regional customs; religion is probably one of the first examples of that.
I’ve heard one of the factors of Buddhism’s proliferation in the east over Hinduism was that it was essentially Hinduism stripped down to its essentials for export. In particular I think it was decoupled somewhat from Indian culture and the caste system. Hugely simplifying things of course.
IIRC Jesus was born actually born around Spring time but the Roman Church decided to move it to Winter to align it better with the harvest festival [citation needed]
China and Korea celebrate Lunar New Year, while Japan decided to use the Gregorian Calendar but in all three cases the festival is pretty big (and is basically again roughly near Christmas)
is there a channel that can offer some code review/suggestions? As the only one here in the office playing with clojure, I'm unsure if what I'm doing is good or not - just want to get some feedback on a very simple project that queries a REST API and displays results
There is also #code-reviews channel
I'll stick it on github and perhaps get some solicitation from this venerable channel
Gists are good @dharrigan
So, here's a little plaything, to help me learn. I'm wondering if
is fine. The thing that sorta irks me, is the call to (first dps)
twice, at line 32 and 33. Is there a better, more idomatic way of writing this?
(btw, if you want to check it out, there are tests that run with example json files)
I'm building up a new map of values, based upon another map (which contains far too many values)
so for each delivery point, extract out only the keys I'm interested in and build up a new map
sorry I'm trying not to spell out my thoughts in case you may get the chance to see improvements yourself
Wondering if select-keys
would make things simpler and I’m not sure of why the loop/recur
I’d personally go for a map
.
if you are doing an element-wise transformation where each transformation can be thought of as being independent map
is usually the one to reach for
if you want to process a sequence where you have access to some intermediate state or do something to combine each individual element then it might be a reduce
@dharrigan looks like you maybe want something like (->> delivery_points (map delivery-point->address) (reduce conj []))
instead of the loop
doh, yeah, i repeatedly forget about mapv
or (apply vector
or (into []
mapv++
surely we need a transducer for this 🙂
re: my postcode thingie, thanks everyone! learnt a lot. I've updated it now and it's much simpler
So, the take-away is that if I see a loop...recur
, then perhaps I should look to see if a map(v)
may be more suitable first?
I found starting from loop recur and then refactoring to higher abstractions has been a useful way to understand those abstractions. For example, I did this in for the first Advent of Code challenge https://www.youtube.com/watch?v=opM7fU7IAV8&list=PLy9I_IfUBzKJSgctCJaRYcnF6kZdiZ5ku&index=6
I also do examples of going from loop recur to higher abstractions in https://github.com/jr0cket/four-clojure
Number 30 and 53 are interesting examples
I guess or anyone of the built in sequence functions...
I think someone built a tool that finds functions based of input and output but I can't remember what it's called
ah yeah that's it
@dharrigan
> So, the take-away is that if I see a loop...recur
, then perhaps I should look to see if a map(v)
may be more suitable first?
as @danieleneal says, if you’re reaching for loop
/`recur` look to the whole sequence api; as it depends why you’re wanting to loop in the first place.
e.g. typically
- If you want to apply a transformation to each element reach for map
/`mapv`
- If you’re looking to remove items, look at things like distinct
, set
, filter
, remove
, keep
…
- If you want to apply a side effect for each element reach for run!
/ doseq
/ doall
…
- If you want to produce a single compound value from many look for specialised functions first, then at reduce
- If you want to produce a sequence of values that depend on the previous value look at iterate
…
- If you need to manipulate something stateful into being a sequence-like thing look at lazy-seq
or a transducers.
There are many many more — for example you might also wonder about using transducers etc; but hopefully the above will give you some clues.
Btw the code you have at the moment looks reasonable.
awesome! thanks @rickmoynihan!
Oh and also loop
/`recur` is occasionally exactly the right tool for the job, but it’s usually only the best option for lower level stuff… e.g. if you’re doing interop; or implementing transducers that do interop, that kinda thing. If you’re looking to do that someone has probably done it for you and put it in a library
Then see if you get your head around this one 🙂 https://gist.github.com/RickMoynihan/c78e33a781910a789a5875b7bb42cbfc
Holy shit! I am away for a couple of hours and you guys start talking about Clojure!! 😉
But now you’re back @wesley.hall it’s all back to normal 🙂