Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Functional Programming is shit

Name: Anonymous 2014-05-12 22:28

Go read any book about functional programming or even features functional programming in the book. You will hear endlessly about how terrible imperative programming is. They will tell you about how functions in imperative languages aren't even real functions and they are error prone and hard to read and all sorts of nonsense. Keep reading that book, not because it has any useful information in it, but because it won't take long before they write a program in an imperative way and even stop to say "oh, it looks like our last program was sort of imperative... i guess shit happens". What they didn't want to point out was the inherent limitations of functional programming.

SICP is especially guilty of this. What's worse is that they insist on comparing everything to C's syntax. Watch as the haskell weenie brags endlessly about being able to implement quicksort in 2 lines. He's too dumb to realize the C version is a few lines longer and an order of magnitude faster.

Stay mad faggots.

Name: Anonymous 2014-05-13 22:23

How do I optimize this


(defn is-queen-attacking? [[other this]]
(or
(= (last other) (last this))
(= (Math/abs (- (last other) (last this))) (- (first this) (first other)))))

(defn is-queen-safe? [queen board]
(empty?
(filter
is-queen-attacking?
(partition 2
(interleave
(map-indexed vector board)
(repeat
(count board)
[(count board) queen]))))))

(defn find-queens-r [board n]
(apply concat
(for [col (range n)
:when (is-queen-safe? col board)]
(if (>= (inc (count board)) n)
[(conj board col)]
(find-queens-r (conj board col) n)))))

(defn find-queens [n]
(find-queens-r [] n))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List