Clojure BASICS

Data Types

Data Structures

Data Types

Data Structures

-----------
-----------
+
++

Edn

(Extensible Data Notation)

Functions

(defn say-hi
  [name]
  (print "Hi " name "!")) 
(fn [name]
  (print "Hi " name "!")

Anonymous fn

(Eval uation)

 (. JAVA Interop)

( LISTS )

 [ Vectors ]

#{ Sets }

{ Maps }

( SEQUENCE )

#(funCtions)

Higher order fns

map

Namespaces

(ns clojureba.skynet)
(defn take-over [world]
  (prn "I'm taking over the " world 
       ", please stand by..."))

(def targets ["Sarah Connor", 
              "John Connor"])

src/clojureba/skynet.clj

REQUIRe

(ns clojureba.terminator
  (:require [clojureba.skynet :as skynet]))
(defn terminate [target]
  (prn "Terminating " target "..."))

(defn terminate-all
  []
  (map terminate skynet/targets)) 

src/clojureba/terminator.clj

Questions?

other Important stuff

  • RecordS

  • Multimethods

  • ProtocoLs

 

Links

Clojure 101

By Juan Facorro

Clojure 101

  • 506