Skip to content

Instantly share code, notes, and snippets.

@tgk
Created January 9, 2017 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgk/a5afc3d5ba17946c71f0abf3cfcf7120 to your computer and use it in GitHub Desktop.
Save tgk/a5afc3d5ba17946c71f0abf3cfcf7120 to your computer and use it in GitHub Desktop.
Notes from the first aarhus.clj meetup and dojo
;; Purpose of aarhus.clj and these meetups
;;; To get better
;;; To meet other Clojure peeps in Aarhus/East Jutland
;; Intro round
;;; Name, interests, experience with Clojure?
;; Agenda
;; Me talking (< 30m)
;; Purpose of aarhus.clj
;; Intro round
;; Introduction to the language
;; Installing Clojure using Leiningen
;; Solving the first couple of 4Clojure problems
;; You hacking! (90m)
;; Install lein on your machine
;; Solve some 4Clojure problems
;; All the time: Hang out and socialise (if you're into that)
;; --- Introduction to the language ---
;;; Parentheses!
(+ 1 2)
(+ 1 2 3)
(- 4 3 2)
;;; Datatypes
nil
42
:foo
"bar"
(= 42 1)
(= "foo" "bar")
(= "foo" "foo")
;;;; Lists
(list 1 2 3)
(list "foo" "bar" "baz")
(conj '(:bar :baz) :foo)
;;;; Vectors
["hello" "world" "!"]
(vec (list 1 2 3))
(vector 4 5 6)
(= (list 1 2 3) [1 2 3])
(conj [:bar :baz] :foo)
([1 2 3] 1)
;;;; Sets
#{1 2 3}
(set '(1 2 3))
(set '(1 1 2 2 3 3))
(conj #{:bar :baz} :foo)
(#{1 2 3} 4)
;;;; Maps
{:a 20, "b" 30}
(hash-map :foo 42, :bar 2)
(conj {:bar 1, :baz 2} [:foo 0])
({:foo 42 :bar 10} :foo)
;;; Built in functions
(first [3 2 1])
(first #{3 2 1})
(first {:foo 0, :bar 2})
(rest [3 2 1])
;;; API
;;;; https://clojure.github.io/clojure/clojure.core-api.html
;;; Functions
(fn [x] (+ x 2))
((fn [x] (+ x 2)) 40)
(map (fn [x] (+ x 2)) '(1 2 3))
(filter (fn [x] (= (mod x 2) 0)) '(1 2 3 4 5 6))
;;; Java interop
(.toUpperCase "hello")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment