Slide 1

Slide 1 text

My Journey in Learning LISP Kadek Byan Prihandana Jati

Slide 2

Slide 2 text

Why LISP • LISP is one of ancient technology in History, 1958 • LISP is based on Pure FP • LISP is said to be core of creational the other modern Programming Language ( Python, Ruby, etc ).

Slide 3

Slide 3 text

What LISP ?

Slide 4

Slide 4 text

LISP is • LISP is pure functional programming language that come from “List Programming”. One of the uniqueness of LISP from other programming language is “Expression-Based” language.

Slide 5

Slide 5 text

What kind of story do i have about LISP ?

Slide 6

Slide 6 text

LISP Story • I started learning LISP about 5 month ago, because someone suggest me that LISP is one of a rare programming language that people not learn nowadays. Hype Mode: On! I was learning LISP then.

Slide 7

Slide 7 text

So, what i have learned about ? * finally *

Slide 8

Slide 8 text

Expression Based Programming 1 + 1 + 1 + 1 + 1 + 1 = (+ 1 1 1 1 1 1) (operator arguments)

Slide 9

Slide 9 text

Evaluation Order on LISP Applicative Order (sum-of-squares (+ 5 1) (* 5 2)) (sum-of-squares 6 10) 136 (defn p [] (if (conditional) 1 (p)) Normal Order (sum-of-squares (+ 5 1) (* 5 2)) (+ (square (+ 5 1)) (square (* 5 2)) ) (+ (* (+ 5 1) (+ 5 1)) (* (* 5 2) (* 5 2))) (+ (* 6 6) (* 10 10)) (+ 36 100) 136

Slide 10

Slide 10 text

Procedures as black-box abstraction sqrt is a function to find square-root’s value of a number by using newton’s method.

Slide 11

Slide 11 text

Recursive Linear - Recursion (factorial 6) (* 6 (factorial 5)) (* 6 (* 5 (factorial 4))) (* 6 (* 5 (* 4 (factorial 3)))) (* 6 (* 5 (* 4 (* 3 (factorial 2))))) (* 6 (* 5 (* 4 (* 3 (* 2 1)))))) Iterative - Recursion (factorial 6) (fact-iter 1 1 6) (fact-iter 1 2 6) (fact-iter 2 3 6) (fact-iter 6 4 6) (fact-iter 24 5 6) (fact-iter 120 6 6) (fact-iter 720 7 6)

Slide 12

Slide 12 text

A bit about Memory Complexity and Time Complexity

Slide 13

Slide 13 text

Going local not global Somehow, when learning LISP, you are feeling bad when you define a bunch of global variable rather than the local ones. Example : (define (f x y)
 (let ((a 1)
 (b 2))
 (+ (* x (square a))
 (* y b)
 (* a b)))) Rather than : (define a 1) (define b 2) (define (f x y)
 (+ (* x (square a))
 (* y b)
 (* a b)))

Slide 14

Slide 14 text

Data Abstraction In OOP we have Class, Method, Variables, Interface, Annotation, etc. And Object Oriented Concept such as Inheritance, Polymorphism, Encapsulation, etc. In LISP, i found the very simple yet clear concept about Data Abstraction and explained through this example :

Slide 15

Slide 15 text

Arithmetic Operations in LISP (define (add-rat x y)
 (make-rat (+ (* (numer x) (denom y))
 (* (numer y) (denom x)))
 (* (denom x) (denom y)))) 
 (define (sub-rat x y)
 (make-rat (- (* (numer x) (denom y))
 (* (numer y) (denom x)))
 (* (denom x) (denom y)))) 
 (define (mul-rat x y)
 (make-rat (* (numer x) (numer y))
 (* (denom x) (denom y)))) 
 (define (div-rat x y)
 (make-rat (* (numer x) (denom y))
 (* (denom x) (numer y)))) 
 (define (equal-rat? x y)
 (= (* (numer x) (denom y))
 (* (numer y) (denom x)))) (define (make-rat x y) (cons x y)) Consider a test case when x = 2/6, y = 4/8. What is the value of (add-rat x y) ? 2/6 + 4/8 = 8/24 + 12/24 = 20/24 Then..

Slide 16

Slide 16 text

2/6 + 4/8 = 8/24 + 12/24 = 20/24 To make the equation simpler, we should divide the numerator and denumerator with GCD(20,24). We could implement divide-by-gcd for each of these function : add-rat, sub-rat, mul-rat, eq-rat but to make it simpler just implement divide-by-gcd on ‘make-rat’ function because the ‘make-rat’ function is a function which composing numerator and denumerator to be a single data. (define (make-rat x y) (let ((g (gcd x y)) (cons (/ x g) (/ y g))) Arithmetic Operations in LISP

Slide 17

Slide 17 text

Abstraction Barriers

Slide 18

Slide 18 text

Bootstrapping Functional Programming Concept Enumerate - Filter - Map - Accumulate Enumerate - Map - Filter - Accumulate In Functional Programming we always heard about HOF Term ( High Order Function ) which means abstracting your function as high as possible. (accumulate + (filter odd (map square (list 1 2 3 4 5)))) = 20 (accumulate + (map square (filter odd (list 1 2 3 4 5)))) = 20

Slide 19

Slide 19 text

Symbolic Data Consider this case : When someone told you to ‘say your name aloud’, what would you do ? a. say your name : as example ‘BYAAN!’ b. say your name : as example ‘YOUR NAMEE!!’ On LISP, we could distinguish that a code which intended to be compiled or not to be compiled. Which means, we could control which code to be compiled and not to be compiled and it is awesome.

Slide 20

Slide 20 text

LISP Advanced Topic 1. Macro 2. Object, State Modelling in LISP 3. Concurrency 4. Building Metacircular Evaluator ( Meta Programming )

Slide 21

Slide 21 text

My Project on LISP Last Year at May 2015 I’ve done my First LISP project and Last Project on my Campus. The project is about building a Recommendation System using an Algorithm called Regularization Kernel Matrix Factorization. But before, let’s talk about my Stack Development which are can’t be presented when i’m about to present it to my Lecturer * they are only concern with the Algorithm Analysis #boooooring *

Slide 22

Slide 22 text

Online RKMF Recommender System LightTable as Editor Equipped with Leiningen. SQL DSL for Clojure Ring/Clojure Routing Component on Clojure weavejester/hiccup HTML Templating on Clojure clojure.core.matrix matrix lib for Clojure

Slide 23

Slide 23 text

DEMO Project

Slide 24

Slide 24 text

Conclusion • LISP is a simple programming language for young hacker/programmer/developer ( you mention it! ), because of it’s clarity guide into Abstraction and Programming Concept. ( young : someone with age < 100 and still alive! ) • LISP is a programming language based on Math ( besides Haskell ) and have a lot of feature that could be hacked or representing Math / AI problem related areas.

Slide 25

Slide 25 text

Literature • SICP ( Structure Interpretation Computer Programming by MIT Press ) • Clojure for the brave and true ( websites ) • Bill The Lizard ( Blog ) • The Joy Of Clojure ( Free - Ebook ) • On LISP ( Paul Graham - Book ) • Clojure-con / Infoq #Clojure