A gentle introduction to functional programming through music and clojure
1. A gentle introduction to
functional programming through
music and Clojure
Mødegruppe for F#unktionelle Københavnere, 24 November, 2015
Presented by Paul Lam
2. Agenda
1. What is functional programming
2. Setting up the environment
3. Making some noise
4. Making some music
5. Transforming data to music
6. Why functional programming
3. Wiki: Functional Programming
“In computer science, functional programming
is a programming paradigm—a style of building
the structure and elements of computer
programs—that treats computation as the
evaluation of mathematical functions and
avoids changing-state and mutable data.”
5. Clojure is a dynamic programming language
that targets the Java Virtual Machine, Common
Language Runtime, and JavaScript
6. Data Literals
Long 42
BigInteger 1234567891234567
8912
Double 1.234
BigDecimal 1.234M
Ratio 22/7
String “fred”
Character a b c
Keyword :a, :foo
Symbol fred, ethel
Boolean true, false
nil nil
Regex #”a*b”
8. Installing Leiningen
Go to http://leiningen.org/ and follow 4 steps
(Note: You must have Java already installed)
1. Download the lein script (or on Windows lein.bat)
2. Place it on your $PATH where your shell can find it (eg. ~/bin)
3. Set it to be executable (chmod a+x ~/bin/lein)
4. Run it (lein) and it will download the self-install package
Then run: $ lein repl // Start a Clojure REPL