Skip to content

Latest commit

 

History

History
72 lines (40 loc) · 1.13 KB

clojure-notes.md

File metadata and controls

72 lines (40 loc) · 1.13 KB

Clojure

http://www.infoq.com/presentations/Simple-Made-Easy

Read the joy of clojure

4Clojure - take a look at:

Projects

Overview

conj - adds an item to the front

List

(:a :b :c)

Vector

[1 2 3]

Set

#(:b :c :d)

Maps

{:a 10, :b 20, :c 30}

first, second, last, rest

Functions

(defn getthing [x] (+ x 2))

(fn helloworld [n] (str "Hello, " n "!" ))

str: s-expression

Specify a single argument:

(+ % 5)

Map

(map #(+ % 5) '(1 2 3))

Filter

(filter #(> % 5) '(3 4 5 6 7)

Return last element of a list without using last:

(fn [x] (first (reverse x)))

Second but last

(fn dostuff [x] (last (butlast x)))

Checkout Lazy Sequences - fibonacci written with lazy cat.