This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-05
Channels
- # adventofcode (95)
- # announcements (3)
- # babashka (11)
- # beginners (39)
- # boot (19)
- # bristol-clojurians (1)
- # cider (32)
- # clj-kondo (39)
- # cljsrn (8)
- # clojure (156)
- # clojure-dev (35)
- # clojure-europe (4)
- # clojure-italy (15)
- # clojure-nl (28)
- # clojure-spec (43)
- # clojure-uk (153)
- # clojurescript (168)
- # core-async (13)
- # core-logic (11)
- # cryogen (4)
- # cursive (13)
- # datomic (26)
- # duct (3)
- # emacs (8)
- # fulcro (33)
- # garden (4)
- # graalvm (18)
- # graphql (4)
- # jobs-discuss (2)
- # kaocha (1)
- # leiningen (3)
- # malli (8)
- # off-topic (1)
- # pathom (7)
- # re-frame (21)
- # reagent (3)
- # rewrite-clj (1)
- # schema (4)
- # shadow-cljs (40)
- # sql (2)
- # uncomplicate (3)
If I want to generate a set of numbers between two known numbers, what's the best way to do that?
(apply range (sort [x y]))
Would this be an appropriate way to go about this?@scott.archer Randomly generated? Any constraints?
(and do you actually want a set or just a sequence?)
Not randomly generated, given 5 and 100 I would need numbers 5 through 100. Given -8 through 5 I would need the numbers -8 through 5.
(range (min x y) (max x y))
or (apply range (sort [x y]))
both seem reasonable then
Min max is better I think as that way I can increment the max by 1 to account for the way range works. Thanks!
Yup, depending on whether you need inclusive/exclusive range ends...
what today should be the recommended approach to create/deploy clojure functions as aws lambdas?
Hello - I’m struggling to eagerly read a 50mb CSV file (numbers and strings). Uses 500mb memory on first read and just runs out of memory on further reads. Have heap as -Xmx1G. What can I do? My code is
(with-open [r (io/reader path)] (doall (csv/read-csv r)))
thanks!looks like a great test case for iota https://github.com/thebusby/iota
Hey All, How do I use the Garden library to generate the CSS and then include it in my project? I understand (css [:h1 {:font-weight "bold"}]) will output the appropriate CSS string, but how do I create a CSS file from this and include it in my ClojureScript project?
If you're using leiningen, the author of garden has a plugin for it that handles the building for you https://github.com/noprompt/lein-garden
No, doesn’t work. I tried that:
java.lang.RuntimeException: No such var: namespace/multiname
hello, I have a simple question, how I can run (into-array Double [ 100 200])
without element type mismatch error ? shouldn't clojure convert integer to double automatically ?
you need to convert integers to doubles. E.g this works: (into-array Double [ 100.0 200.0])
what if (into-array Double INPUT-LIST)
should I map the INPUT-LIST with like ' map #(to-double) INPUT-LIST '?
yeah, that's right but looks a little bit odd, if 95% chances INPUT-LIST is floated based, then the mapping function is causing unnecessary overhead for CPU.
thank you for your reply anyway
kind of a meta question… what would be the appropriate channel to share something we’ve built with Clojure?
if it's a company kind of thing, would love to have a company story for http://clojure.org! https://clojure.org/community/community_stories
@alexmiller it’s a solo / single developer effort. a small web app i built and launched today. but wanted to ask vs just posting a product hunt link.
or #announcements
When checking a set for a value to use in an if statement is it more idiomatic and/or clear to use (#{values} value)
or (contains? #{values} value)
? The former returns the value or nil and the latter is true or false right, but in a conditional those both kind of do the job I think.
Check out https://guide.clojure.style/#set-as-predicate - it's a good place to figure out if you are doing things in a reasonably idiomatic way, and in this case it agrees with the way I do things normally so it must be right 🙂
Oh wow, this looks like a great resource. And extensive! Not sure how I overlooked this one
Also note that if the set you are interested in checking membership in contains nil
or false
, then (#{values} value)
will return nil
or false
when it successfully finds an element, whereas contains?
will return true in those cases. If it is a literal compile-time constant set that contains neither nil
nor false
, no problem. If it is a run-time variable set that you do not know whether it contains those values, I'd recommend contains?
ahh, that is a great point! I was doing some advent of code stuff so the input had no nil
or false
values in it.
In general, nil or false values in sets are an issue in many places and it’s best to just not do that ever
also NaN
user=> (into #{##NaN} [##NaN ##NaN])
#{##NaN ##NaN ##NaN}