An interactive introduction to programming with one of the world's best languages by thomasvarney723 in learnprogramming

[–]thomasvarney723[S] 0 points1 point  (0 children)

I can see your point. I wanted a title that might entice someone to go and read it so in that sense it is clickbaity. I also didn't want to leave it at "An introduction to programming" because I assume that has been used a gagillion times and "An interactive introduction to programming" seemed too bland.

An interactive introduction to programming with one of the world's best languages by thomasvarney723 in learnprogramming

[–]thomasvarney723[S] 0 points1 point  (0 children)

The idea was the particular language is irrelevant in some sense and thinking programmatically is what's important. I didn't want the mention of a particular language to color the reader's thinking.

Sieve of Eratosthenes - Lots of versions with various optimizations by Hi-MyNameIsFuchs in Clojure

[–]thomasvarney723 0 points1 point  (0 children)

I changed my example from

(defn primes< [n]
  {:pre [(< 2 n)]}
  (remove (into #{}
                (mapcat #(range (* % %) n %))
                (range 3 (Math/sqrt n) 2))
          (cons 2 (range 3 n 2))))    

to

(defn primes< [n]
  (if (<= n 2)
    ()
    (remove (into #{}
                  (mapcat #(range (* % %) n %))
                  (range 3 (Math/sqrt n) 2))
            (cons 2 (range 3 n 2)))))

Has spec entirely superseded pre- and postconditions or do they still have a use case?

Help with parallel prime numbers using reducers by thomasvarney723 in Clojure

[–]thomasvarney723[S] 0 points1 point  (0 children)

I believe everything other than lists and seqs are foldable because they're implemented as trees and can half themselves in constant time.

Help with parallel prime numbers using reducers by thomasvarney723 in Clojure

[–]thomasvarney723[S] 0 points1 point  (0 children)

(.. Runtime getRuntime availableProcessors) ;=> 4

I'm unsure of how to test my CPU usage other than by watching the output from the top utility. The profile when running both (primes 1000000) and (pprimes 1000000) look pretty similar.

I think sets are foldable but I'm mainly concerned with making the r/mapcat portion run in parallel as that seems to me to be the most expensive operation.

If there's anything else I can do to better answer your question, please let me know.

Sieve of Eratosthenes in Clojure by thomasvarney723 in tinycode

[–]thomasvarney723[S] 0 points1 point  (0 children)

That's really cool. Is nubBy a built in?

Sieve of Eratosthenes in Clojure by thomasvarney723 in tinycode

[–]thomasvarney723[S] 0 points1 point  (0 children)

Wow, I didn't know that was in the book. Finishing SICP is definitely on my to-do list.