This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-17
Channels
- # aleph (3)
- # announcements (12)
- # beginners (80)
- # boot (3)
- # braveandtrue (16)
- # calva (3)
- # cider (82)
- # clojure (100)
- # clojure-art (3)
- # clojure-dev (79)
- # clojure-estonia (1)
- # clojure-europe (4)
- # clojure-finland (15)
- # clojure-indonesia (1)
- # clojure-italy (20)
- # clojure-nl (4)
- # clojure-spec (24)
- # clojure-sweden (2)
- # clojure-switzerland (1)
- # clojure-uk (99)
- # clojurescript (145)
- # cursive (8)
- # data-science (7)
- # datomic (26)
- # emacs (4)
- # figwheel-main (20)
- # fulcro (8)
- # graphql (3)
- # hoplon (2)
- # jobs (1)
- # kaocha (5)
- # leiningen (2)
- # liberator (19)
- # off-topic (16)
- # pathom (9)
- # perun (1)
- # portkey (2)
- # re-frame (17)
- # reitit (1)
- # shadow-cljs (26)
- # spacemacs (7)
- # vim (49)
eg. (cons x (when ...))
relies on nil both being falsey and acting like an empty list for cons
(commonly seen in lazy seq generation)
Hi. I'm looking for some feedback. Core.match is great, but I'm getting the sense that I'm abusing it. How would you refactor this https://github.com/aaron-santos/robinson/blob/master/src/robinson/ui/cell.clj#L64 ?
I would personally break it down into these three vars:
so you never care about the water level being less than 10. and then you only care about a trap is found in two cases. \O
becomes \~
and \.
becomes \^
. So really you can just have a direct table of cell type to character and if a trap is found and its a symbol that has a trap-found modifier, do that
(defn cell->cp437-character [c trap?] (let [base (cell-lookup c)] (if trap? (trap-lookup c c) c)
"look up the base character. if there's a trap, see if there's a special trap symbol (`{\O \~ \. \^}`) else return c"
Great point! I'll try that out. Thank you
do I understand correctly that if I call nth
on a lazy sequence, it will be realized only once?
sequences are cached as they’re computed so you never realize an element of the sequence more than once
then, yes
hey, trying to use clojure gradle plugin, and when I run gradlew.bat build my clojure .clj ends up in the jar, and looks like whole clojure also, but I don't see gen-class(ed) class produced... what do I miss?
Hey all, I’m having some trouble using react native with clojurescript. I’ve tried using it with expo and re-natal and keep getting errors. When I use lein new expo “projectname” it will make the project but when I do the && yarn install it returns: “react-native > metro > @babel/[email protected]" has incorrect peer dependency “@babel/[email protected]”. When I try and use re-natal, I get “command failed: lein prod-build. Any thoughts?
Hey @dgonsalves22 I don't know if this will help, but I just found
In that he mentions the incorrect peer dependency issue you are having. To solve it, in your case you may need to add @babel/[email protected]
to your package.json.
Literally new to all of this, but came across that. So, I hope it helps!I might need to post the actual code I wrote, but does anyone know why my loop/recur
form that paged through objects in an S3 bucket just caused CIDER to hang this morning? I fixed it by switching to normal recursion. Am I missing something about loop/recur
Sounds like it got into an infinite loop somehow.
Yeah… I thought I had my early exit correct, but you’re probably right. But in theory, there’s nothing wrong with loop/recur
, even for tasks that may take a few seconds per loop, right?
right
Using http://reagent-project.github.io/ - later config app to run inside Electron Wrapper as explained at https://getstream.io/blog/takeaways-on-building-a-react-based-app-with-electron/
user=> (defn whatever-function [] (prn 123)
#_=> [& {:keys argument-1}] (prn argument-1))
and later on I could do something like this
user=> (defn whatever-function [] (prn 123)
#_=> [& {:keys argument-1}] (prn argument-1)
#_=> [& {:keys argument-2 argument-3}] (prn argument-2))
you can't have an empty arg list and all args optional as arities
also arity dispatch can't select based on presence or absence of keys
maybe you want a multimethod?
a multimethod can differentiate between an empty arg list and optional keys, regular arity dispatch can't
@pmachadogabriel the key with multimethods is you write at least two functions - one that looks at all your args and decides how to dispatch, and another that gets called when a given dispatch is matched
thanks a lot @noisesmith I feel that this is what I was looking for
in general, if you do the & {} thing for named args, at some point you will want to apply that function, and you will have to write mapply, and it is silly
@pmachadogabriel there are several libraries to build REST stuff, e.g. yada
So what I was trying to achieve was some pattern matching whenever a parameter is nil
and I've managed to find core.match, but I'm not sure if its a idiomatic way to write clojure
FWIW Rich Hickey has extensive arguments for why he didn't implement matching in clojure.core, and why he thinks people should use multimethods instead of pattern matching.
Hey @noisesmith is there any talks or articles about that? I would be interesting in reading them
I'm sure the talk is on youtube... I'll have to remember which one it was
@dustin.lahr.367 I think this is the one https://www.youtube.com/watch?v=2V1FtfBDsLU&t=37m07s
Thanks!
I think the executive summary is that it’s not predictably fast
user=> (defmulti create-person (fn [data] {:age (contains? data :age) :height (contains? data :age)}))
user=> (defmethod create-person {:age true :height true} [_] (prn "age and height"))
user=> (create-person {:age 10 :height 10})
"age and height"
@noisesmith I've come up with this
you can create a :default
method (defmethod create-person :default ...)
for the most generic case
but in your case there are only 4 possible method implementations
yeah, that makes sense as a dispatch value