Fork me on GitHub

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.


A sequence or set is fine.


(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...


Thanks again, I really appreciate the time you spend helping others!

😊 4

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)))


I think doseq would solve this


doall forces all into memory, doseq does one-at-a-time.


looks like a great test case for 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


Hello. How do I remove-method which was defmethod in another namespace?


(remove-method namespace/multiname dis-value)?


No, doesn’t work. I tried that: java.lang.RuntimeException: No such var: namespace/multiname

Xiaoyu Zhang14:12:13

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])


or (into-array Double (map #(.doubleValue %) [100 200]))

Xiaoyu Zhang14:12:55

what if (into-array Double INPUT-LIST) should I map the INPUT-LIST with like ' map #(to-double) INPUT-LIST '?

Xiaoyu Zhang15:12:07

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.

Xiaoyu Zhang15:12:26

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!


@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


cool thanks alex!


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 - 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?

👍 4

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


user=> (into #{##NaN} [##NaN ##NaN])
#{##NaN ##NaN ##NaN}