Touch the firehose of ds106, the most recent flow of content from all of the blogs syndicated into ds106. As of right now, there have been 92731 posts brought in here going back to December 2010. If you want to be part of the flow, first learn more about ds106. Then, if you are truly ready and up to the task of creating web art, sign up and start doing it.

Daniel on Lazy Sequences

Posted by
|
Looking into Lazy Sequencing and following the link that Patrick found. I discovered that there is very much pattern matching going on with Clojure. Check this (it’s also a polymorphic function as it can appear differently depending on how its called).
(defn argcount
;;zero arguments
([] 0)

;; 1 argument
([x] 1)

;; list of arguments
([ x &  args] (inc (count args))))

no if then statements, this is defining a function lazily, it only grabs the definition that it needs :) pretty neat.

This language is a very functional language much like SML. Here’s another example of a function being defined on one line
(def newton (iterate (fn[x] (/ (+ x (/ 2.0 x)) 2)) 2))

Here is an example of a for loop which cannot be done in SML. I like Clojure better already :)

for loop

user=> (dotimes [i 4] (prn i))
0
1
2
3

Add a comment

ds106 in[SPIRE]