Skip to content

Instantly share code, notes, and snippets.

@hindenbug
Last active December 31, 2015 23:29
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 hindenbug/8059923 to your computer and use it in GitHub Desktop.
Save hindenbug/8059923 to your computer and use it in GitHub Desktop.
Clojure Adventures - MileStone 1
  • Clojure, the core data structures aren't mutable

Clojure Data Structures

Clojure has two types of expressions atoms and collections

ATOMS

Atoms represent Primitive Types in other languages, like:
Numbers, Strings, Boolean, Nil, Symbols, Keywords

  1. Numbers
    2
    1.5

  2. Strings
    A valid string example with ""

    (println "Hello World")  
    => Hello World 
     
    (println "\"Hello World\"")  
    => "Hello World"

    Invalid String example with ''

    (println 'Hello World')  
    => clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable      to resolve symbol: World' in this context, compiling:(null:5:1)

    Note: Clojure doesn't have string interpolation

  3. Boolean
    true false

  4. Nil - Clojure’s name for no-value
    nil

  5. Symbols (Not to be confused with Ruby's symbols)
    Symbols in clojure are like identifiers to refer to something like variables in other laguages. As clojure does not have variables.

  6. Keywords (They bind to themseleves)
    Primarily used as keys in hashes/maps
    :key :1234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment