This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-03
Channels
- # arachne (31)
- # aws (9)
- # bangalore-clj (7)
- # beginners (46)
- # boot (18)
- # cider (21)
- # cljs-dev (8)
- # clojure (154)
- # clojure-dusseldorf (5)
- # clojure-filipino (3)
- # clojure-ireland (4)
- # clojure-italy (9)
- # clojure-russia (6)
- # clojure-spec (6)
- # clojure-uk (52)
- # clojureremote (3)
- # clojurescript (173)
- # clojurewest (14)
- # cursive (24)
- # data-science (2)
- # datomic (18)
- # defnpodcast (1)
- # devcards (1)
- # hoplon (4)
- # instaparse (29)
- # jobs (2)
- # juxt (1)
- # leiningen (3)
- # lumo (78)
- # off-topic (46)
- # om (9)
- # onyx (42)
- # pedestal (33)
- # perun (3)
- # re-frame (9)
- # reagent (6)
- # slack-help (5)
- # spacemacs (2)
- # specter (6)
- # unrepl (157)
- # untangled (99)
- # yada (32)
Hello! I'm looking for a way annotate errors without exceptions: Something that evaluates to false and can contain information about why. Any suggestions?
Example: a function mk-error
that makes this return "nay": (if (mk-error {:message "File not found"}) "yay" "nay")
Also, you can't. nil
and false
only evaluate to false and you can't attach data to them. They're constants
Another question. Why use records when we have maps? My gut feeling is that records might be faster in some cases because you can "centralize" the key storage. Thoughts?
defrecord is definitely faster than a map, among some other differences - https://github.com/plumatic/eng-practices/blob/master/clojure/20130926-data-representation.md
whats the best way to 'subtract' one set from another? I have two lists (or sets or vectors, whatever is easiest) of strings and I want to find items that are in set A but not B
well that was easy https://clojuredocs.org/clojure.set/difference
Many functions in clojure.set are garbage-in-garbage-out (types are not checked to minimize bytecode size so JVM considers inlining it even with default settings). Make sure to pass sets where required.
What would you recommend to be good read about functional programming and lisps in general for beginners? SICP is great i am doing it right now. i was just wondering what would people here recommend beside that 🙂
does anyone have any experience getting custom react components, compiled with webpack working in cljs?
So far I have found out, that compiling js into UMD with webpack was the best way to go but haven’t found either the right webpack config or project.clj config
Are Clojure-mode and cider the 2 basic packages you need to get up and running in emacs? I've installed them both, but I just want to make sure I haven't forgotten anything... 🙂 At least no error messages...
Is there a nicer way to write this?
(reduce (fn [c x] (+ c (:a x))) 0
[{:a 1} {:a 2}])
I was hoping this, but no avail:
(apply (comp + :a) [{:a 1} {:a 2}])
@josh.freckleton does that help?
it cut off my comment- that's another option
thanks @djz, that's a start, and I think @noisesmith nailed it, this may be a transduction problem, because then I can compose those transducing fns too
thanks!
I feel like I get transducers pretty well, but I need to start seeing when to use them
@josh.freckleton I like to ask myself "does this create a lazy seq I never consume?" - if so, there's often a transduce which can replace it
never directly consume that is
you mean I'll never need the list of (map :a ...)
, so transduce over it?
does this give an efficiency gain too then?
right - same if you see a filter, a concat, etc. in your intermediate calculation that the result doesn't need directly
yes - at least a small one
thank you!
I need to make my language more explicit, "there's often a way to use a transducer which can replace the usage of a lazy seq" - it might involve eg. into or core.async/chan or even sequence, where these each use a transducer