Skip to content

Instantly share code, notes, and snippets.

@jdivock
Last active August 29, 2015 14:06
Show Gist options
  • Save jdivock/0829ca8b22e57e559601 to your computer and use it in GitHub Desktop.
Save jdivock/0829ca8b22e57e559601 to your computer and use it in GitHub Desktop.
ClojureScript scratch
;; Anything you type in here will be executed
;; immediately with the results shown on the
;; right.
( #(conj %1 %2 %3) {"foo" "bar"} {"zub" "bub"} { "hi" "there"} )
( (fn [yep stuff] (conj yep stuff)) {"foo" "bar"} {"zub" "bub"} )
( #(* 2 %) 5)
( [1 2 3] 1)
( conj [1 2 3] 19)
(assoc [1 2 3] 0 10)
(def foo { :hi 1, :boo 2} )
(let [x foo])
(foo :hi)
(get foo :hi)
(:hi foo)
(assoc foo :jay "dee" :barron "robber")
(def jaySet #{1 , 2, 3})
(conj jaySet 1)
(conj jaySet 10)
(def my-atom (atom { :test, 123 }))
@my-atom
(swap! my-atom assoc :bee "hive")
@my-atom
(reset! my-atom {:jay "far"})
@my-atom
(map #(* 2 %) [0, 1, 2, 3, 4])
(map #(* 2 %) (take 10 (iterate inc 0)))
(map (fn [foo bar] (* 2 foo bar)) [1 2 3 4 5] [1 2 3 5 6 7])
(reduce (fn [arg1 arg2] (* arg1 arg2)) [1 2 3 4 5])
(reduce #(* %1 %2) [1 2 3 4 5])
(take 10 (iterate inc 0))
'hi 'there
'(when ?even 2)
(take 5 (filter even? (range 10)) )
(take 5 (filter (fn [x] (= (rem x 3) 0)) (range)))
(loop [x 10]
(when (> x 0)
(if (= (rem x 3) 0) (println x) )
(recur (- x 1))))
(take 10 (cycle "LOL"))
(* 2 ( filter even? (range 10)))
(for [x (filter even? (range 10))
:let [y (* x 2)]
]
y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment