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

3671c3425bbbc1de94d87374617646b7?s=128

Ricardo J. Méndez

September 13, 2017
Tweet

Transcript

  1. 4.

    @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. 6.

    @ArgesRic Learning stages • First we learn by reading; •

    Then we learn by imitating; • And finally, we learn by creating.
  3. 10.
  4. 12.
  5. 13.
  6. 15.
  7. 44.

    @ArgesRic ( defn plus-one ; All these [v w] ;

    are (+ w v 1) ; parameters. )
  8. 46.

    @ArgesRic ( defn plus-one [v w] ; This is a

    vector w/param ids (+ w v 1) )
  9. 47.

    @ArgesRic ( defn plus-one [v w] (+ w v 1)

    ; This is a list to evaluate )
  10. 48.

    @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 )
  11. 50.

    @ArgesRic ( defn get-from-string [conn long-url] ( let [url (db/get-url

    conn long-url) parsed (db/parse url)] (clean-up parsed) ) )
  12. 51.

    @ArgesRic ( defn get-from-string [conn long-url] ( let [url (db/get-url

    conn long-url) parsed (db/parse url)] (clean-up parsed) ) )
  13. 52.

    @ArgesRic ( defn get-from-string [conn long-url] ( let [url (db/get-url

    conn long-url) parsed (db/parse url)] (clean-up parsed) ) )
  14. 53.

    @ArgesRic ( defn get-from-string [conn long-url] ( let [url (db/get-url

    conn long-url) parsed (db/parse url)] (clean-up parsed) ) )
  15. 59.

    @ArgesRic (defn a-function [v] [+ 1 2 3 4 5]

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

    @ArgesRic (defn a-function [v] [+ 1 2 3 4 5]

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