This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-10
Channels
- # asami (2)
- # babashka (28)
- # beginners (91)
- # calva (38)
- # cider (7)
- # clj-kondo (20)
- # cljfx (3)
- # clojure (88)
- # clojure-austin (1)
- # clojure-australia (2)
- # clojure-bay-area (10)
- # clojure-europe (68)
- # clojure-france (8)
- # clojure-italy (14)
- # clojure-nl (4)
- # clojure-sanfrancisco (1)
- # clojure-uk (14)
- # clojurescript (37)
- # clojureverse-ops (14)
- # clojurewerkz (1)
- # clr (1)
- # conjure (13)
- # cursive (10)
- # datascript (30)
- # datomic (6)
- # emacs (13)
- # exercism (3)
- # fulcro (10)
- # graalvm (4)
- # graphql (2)
- # instaparse (5)
- # jobs (3)
- # kaocha (10)
- # off-topic (20)
- # pathom (17)
- # polylith (7)
- # re-frame (25)
- # remote-jobs (1)
- # shadow-cljs (60)
- # spacemacs (5)
- # specter (1)
- # startup-in-a-month (1)
- # tools-deps (48)
- # vim (4)
- # xtdb (11)
hey all, i just woke up :D 6am in oslo. if you're interested, here are the slides from the talk https://github.com/oakes/bay-area-odoyle i couldn't be bothered to use slide software like a normal person so i made it in the form of a play-cljc game
@youngil if you have a chance, could you post an example of what you meant about functional style looking like a graph tree (sorry, paraphrasing maybe incorrectly)? I'm interested in different styles of Clojure code/thinking.
Sure. I mean something like: (f1 (f2 x (f4 y)) (f3 (f5 a b) (f6 c d))) which doesn't have a simple rewrite using ->, as opposed to (f1 (f2 (f3 (f4 (f5 (f6 x))))))
I see. This happens all the time. Taking (f5 a b)
as a simplistic example, I would in-line that with (partial f5 a b)
such that the whole block can be rewritten as a ->
. Thoughts?
Not sure what is achieved by (partial f5 a b).
Would you mind reformulating my
(f1 (f2 x (f4 y)) (f3 (f5 a b) (f6 c d)))
using the ->
?
oh my bad, I misread. which does highlight why that is hard to read though. π
here's my attempt to make it clearer,
I'm a fan of descriptive fn name and arguments. So first step is to wrap the whole thing with a descriptive fn name and name each of the args in a map. Using a map as the arg here so we don't need to remember the arity and positions.
And then making use of let
to name results of f2 and f3.
(defn f1-with-clear-name
[{a-named :a
b-named :b
c-named :c
d-named :d
x-named :x
y-named :y}]
(let [named-f3 (f3 (f5 a-name b-name) (f6 c-name d-name))
named-f2 (f2 x-named (f4 y-named))]
(f1 named-f2 named-f3)))
Which goes back to what you were saying about imperative style isn't necessarily bad. Took me a bit to realize what you were saying. But thanks!Agreed that nesting of function calls is harder to read. So, naming the arguments in a let is fine. The only down side is that it does make it look like sequential actions even though it may not be. It may be a matter of getting used to the nested expressions, but I realize that the Clojure convention is to prefer not to nest deeply.
@sekao That was a very interesting talk which made it clear that a rule engine is very useful in the front end.
Thank you !
https://github.com/oakes/odoyle-rules this morning and am brimming with ideas for static blogs and games. Canβt wait to try it out.