Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Reading Clojure

Reading Clojure

If there's one thing that trips Clojure newcomers is how to read the damned thing.

Clojure's syntax is very simple, and yet newcomers to Clojure tend to project into the language the complexity of other languages they're used to. We'll go through a few Clojure examples and deconstruct them to show how there's even less syntax to it than you probably think.

Video: https://youtu.be/t_T5wtLyZos

Ricardo J. Méndez

September 13, 2017
Tweet

More Decks by Ricardo J. Méndez

Other Decks in Programming

Transcript

  1. @ArgesRic Show of hands • Who here isn't programming in

    Clojure yet? • Who is kind of familiar with the language but still finding their footing? • Who considers themselves to be fully comfortable in it?
  2. @ArgesRic Learning stages • First we learn by reading; •

    Then we learn by imitating; • And finally, we learn by creating.
  3. @ArgesRic ( defn plus-one ; All these [v w] ;

    are (+ w v 1) ; parameters. )
  4. @ArgesRic ( defn plus-one [v w] ; This is a

    vector w/param ids (+ w v 1) )
  5. @ArgesRic ( defn plus-one [v w] (+ w v 1)

    ; This is a list to evaluate )
  6. @ArgesRic ( defn ; We are invoking this plus-one ;

    This is an identifier [v w] ; This is a vector w/param ids (+ w v 1) ; This is a list to evaluate )
  7. @ArgesRic ( defn get-from-string [conn long-url] ( let [url (db/get-url

    conn long-url) parsed (db/parse url)] (clean-up parsed) ) )
  8. @ArgesRic ( defn get-from-string [conn long-url] ( let [url (db/get-url

    conn long-url) parsed (db/parse url)] (clean-up parsed) ) )
  9. @ArgesRic ( defn get-from-string [conn long-url] ( let [url (db/get-url

    conn long-url) parsed (db/parse url)] (clean-up parsed) ) )
  10. @ArgesRic ( defn get-from-string [conn long-url] ( let [url (db/get-url

    conn long-url) parsed (db/parse url)] (clean-up parsed) ) )
  11. @ArgesRic (defn a-function [v] [+ 1 2 3 4 5]

    (plus-one 2 3) plus-one [inc] [inc 1] v)
  12. @ArgesRic (defn a-function [v] [+ 1 2 3 4 5]

    (plus-one 2 3) plus-one [inc] [inc 1] v)