Last active
August 29, 2015 14:19
-
-
Save jboverfelt/d8292d0a3e408906563d to your computer and use it in GitHub Desktop.
whirlwind-clojure.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; clojure has all the basic datatypes - string, double, float, boolean | |
; it also has symbols, keywords, and nil instead of Java's null | |
; a symbol (an identifier that usually refers to something else | |
'test | |
; a keyword (generally used in maps and for "enum" like values) | |
:foo | |
; Data Structures | |
; vector (sequential, add new values at end) | |
[1 2 3] | |
; list (clojure code is made up of lists, sequential | |
'(1 2 3) | |
; map (hash map) | |
{:foo bar :test 123} | |
; set | |
#{1 2 3} | |
; functions (it's a list!) | |
; general form | |
(defn function [arg arg arg ...] | |
...) | |
(function arg arg arg) | |
(defn add-2 [other] | |
(+ 2 other)) | |
(add-2 3) ; => 5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment