Skip to content

Instantly share code, notes, and snippets.

Last active March 17, 2021 20:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save apropos-cast/810beaf9353e014de339172c9bda0444 to your computer and use it in GitHub Desktop.
Apropos March 10, 2021

Show Notes


Follow-up on tagged literals from last episode

Tagged Literal type (added Clojure 1.8, 2018):

(set! *default-data-reader-fn* tagged-literal)


Update on Grokking Simplicity (Eric's book)

Dynamically implementing protocols

REPL Time!!

Pattern matching

When describing rhyming patterns, poets use letters to define patterns, like this:

Roses are red A
Violets are blue B
Sugar is sweet C
and so are you B

This poem has an ABCB rhyming structure because the B lines rhyme and A and C do not.

We'll use this same naming scheme but use equality instead of rhyming. Write a function that takes a sequence of values and a pattern string. It returns a a map of letters to values if the pattern matches, and nil if it does not.


(pattern [1 2 1 2] "ABAB") ;=> {\A 1 \B 2}
(pattern [1 2 3 2] "ABCB") ;=> {\A 1 \B 2 \C 3}
(pattern [1 2 3 4] "ABAB") ;=> nil
(pattern [1 1 1 1] "A") ;=> nil (wrong number of elements)
(pattern [1 1 1 1] "ABCD") ;=> {\A 1 \B 1 \C 1 \D 1}
(pattern [1 4 2 1] "ADCA") ;=> {\A 1 \D 4 \C 2}

Where to join us

Discord - Join if you want to watch us live or chat!

Recording and playback on YouTube -

Follow us on Twitter for updates -

Copy link

uwo commented Mar 17, 2021

Love the show. Two concerns:

  1. Spec is ultimately aimed at fine-grained dependencies. It frustrates me when whole conversations go on without that being said.
  2. Rich has said mea culpa. It's the point of his talk "Maybe Not".

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