Slide 1

Slide 1 text

( Chennaipy Feb 2015

Slide 2

Slide 2 text

Hy!

Slide 3

Slide 3 text

Shrayas Logic Soft

Slide 4

Slide 4 text

A Lisp powered Python

Slide 5

Slide 5 text

A Python powered Lisp

Slide 6

Slide 6 text

Lisp

Slide 7

Slide 7 text

Lisp?

Slide 8

Slide 8 text

John McCarthy 1958

Slide 9

Slide 9 text

Polish Notation

Slide 10

Slide 10 text

1+1

Slide 11

Slide 11 text

INFIX 1+1

Slide 12

Slide 12 text

+ 1 1

Slide 13

Slide 13 text

+ 1 1 POLISH

Slide 14

Slide 14 text

(+ 1 1)

Slide 15

Slide 15 text

(+ 1 1) S-EXPRESSIONS

Slide 16

Slide 16 text

(+ 1 1) S-EXPRESSIONS Function

Slide 17

Slide 17 text

(+ 1 1) S-EXPRESSIONS Arguments

Slide 18

Slide 18 text

Variable Arity!

Slide 19

Slide 19 text

1 + 2 + 3 + 4 + 5 Infix

Slide 20

Slide 20 text

(+ 1 2 3 4 5) 1 + 2 + 3 + 4 + 5 Infix S-Expressions

Slide 21

Slide 21 text

Dialects

Slide 22

Slide 22 text

Dialects Arc, AutoLISP, Clojure, Common Lisp, Emacs Lisp, EuLisp, Franz Lisp, Interlisp, ISLISP, LeLisp, LFE, Maclisp, MDL, Newlisp, NIL, Picolisp, Portable Standard Lisp, Racket, Scheme, SKILL, Spice Lisp, T, XLISP, Zetalisp

Slide 23

Slide 23 text

Dialects Arc, AutoLISP, Clojure, Common Lisp, Emacs Lisp, EuLisp, Franz Lisp, Interlisp, ISLISP, LeLisp, LFE, Maclisp, MDL, Newlisp, NIL, Picolisp, Portable Standard Lisp, Racket, Scheme, SKILL, Spice Lisp, T, XLISP, Zetalisp

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

hylang.org @paultag et al.

Slide 26

Slide 26 text

Getting & Running $ pip install hy $ hy

Slide 27

Slide 27 text

Lisp

Slide 28

Slide 28 text

Lisp in Python

Slide 29

Slide 29 text

Why?

Slide 30

Slide 30 text

Pythonic Lisp 1

Slide 31

Slide 31 text

Absurd Powers!!!!1 2

Slide 32

Slide 32 text

Learn Lisp 3

Slide 33

Slide 33 text

SICP

Slide 34

Slide 34 text

Great Py Interop 4

Slide 35

Slide 35 text

Code!

Slide 36

Slide 36 text

def say_hello(name): print "Hello", name if __name__ == "__main__": say_hello("Python") python Hello, python

Slide 37

Slide 37 text

def say_hello(name): print "Hello", name if __name__ == "__main__": say_hello("Python") (defn say_hello [name] (print "Hello" name)) (if (= __name__ "__main__") (say_hello "python")) python hylang Hello, python

Slide 38

Slide 38 text

python Data Structures >>> [1,2,3] >>> {"foo": 1, "bar": 2, "baz": 3} >>> (1,2,3)

Slide 39

Slide 39 text

python hylang Data Structures >>> [1,2,3] >>> {"foo": 1, "bar": 2, "baz": 3} >>> (1,2,3) => [1 2 3] => {"foo" 1 "bar" 2 "baz" 3} => (, 1 2 3)

Slide 40

Slide 40 text

python Fn on Objects >>> "Hello World".upper() ”HELLO WORLD"

Slide 41

Slide 41 text

python hylang Fn on Objects >>> "Hello World".upper() ”HELLO WORLD" ⇒ (.upper "Hello world") "HELLO WORLD"

Slide 42

Slide 42 text

python Conditionals if (foo > 5): print "foo more than 5!" else: print "foo less than 5!"

Slide 43

Slide 43 text

python hylang Conditionals if (foo > 5): print "foo more than 5!" else: print "foo less than 5!" (if (> foo 5) (print "foo more than 5!") (print "foo less than 5!"))

Slide 44

Slide 44 text

python Conditionals (more) if (foo > 7): print "Too much" elif (foo < 7): print "Too less" else: print "ok :)"

Slide 45

Slide 45 text

hylang Conditionals (more) (cond [(> foo 7) (print "Too much")] [(< foo 7) (print "Too less")] [true (print "ok :)")])

Slide 46

Slide 46 text

python Loops for i in xrange(10): print i

Slide 47

Slide 47 text

python hylang Loops for i in xrange(10): print i (for [i (xrange 10)] (print i))

Slide 48

Slide 48 text

hylang Hy import Py (import os) (if (not (os.path.isdir "/foo/bar")) (os.mkdir "/foo/bar"))

Slide 49

Slide 49 text

hylang (hymath.hy) Interop! (defn square [x] "returns square of x" (* x x))

Slide 50

Slide 50 text

python (usemath.py) hylang (hymath.hy) Interop! (defn square [x] "returns square of x" (* x x)) import hy import hymath print hymath.square(8)

Slide 51

Slide 51 text

Recap

Slide 52

Slide 52 text

hylang is a pythonic lisp 1 Recap

Slide 53

Slide 53 text

hylang is a pythonic lisp 1 Has great interop with python 2 Recap

Slide 54

Slide 54 text

hylang is a pythonic lisp 1 Has great interop with python 2 Great excuse to learn Lisp 3 Recap

Slide 55

Slide 55 text

hylang is a pythonic lisp 1 Has great interop with python 2 Great excuse to learn Lisp 3 A new language 4 Recap

Slide 56

Slide 56 text

Fin @shrayasr