SlideShare a Scribd company logo
1 of 22
A Brief Introduction to 
Lisp Language 
Tianyu Gu 
tigu1400@student.miun.se
A Brief History 
● Originally specified in 1958, Lisp is the second-oldest high-level 
programming language in widespread use today; only Fortran is 
older (by one year). 
● Lisp stands for LISt Processing(while Fortran stands for 
FORmula TRANslator). 
● 1958 ~ 1980: Various dialects and systems, MacLisp, InterLisp, 
and Lisp Machines. 
● 1975 ~ 1980: Scheme, the first dialect choosing lexical scope, 
developed in MIT. 
● 1980 ~ 1990: Common Lisp, an industry-level language, 
published in ANSI standard. 
● 1990 ~ Now: Various implementation for Common Lisp and 
Scheme; More 3rd party libraries; A new dialect Clojure.
First Impression 
// C Code 
int factorial(int n){ 
if(n==0) 
return 1; 
else 
return n * 
factorial(n-1); 
} 
;; Common Lisp Code 
(defun factorial (n) 
(if (= n 0) 
1 
(* n 
(factorial (- n 
1)))))
First Impression: Evolution 
// C code, using tail recursion 
int factorial_helper(int result, int count){ 
if(count == 0) return result; 
else 
return factorial_helper(result*count, count-1); 
} 
int factorial(int n){ 
return factorial_helper(1, n); 
} 
;; Common Lisp code, using tail recursion 
(defun factorial (n) 
(declare (optimize (speed 3))) 
(labels ((iter (result count) 
(if (= count 0) 
result 
(iter (* result count) (1- 
count))))) 
(iter 1 n)))
First Impression: Final 'Product' 
;;;; can even use a function called ‘disassemble’ 
;;;; to check the assemble code. 
(defun factorial (n) 
(declare (optimize (speed 3))) 
(labels ((iter (result count) 
(declare (type fixnum result count)) 
(if (= count 0) 
result 
(iter (the fixnum (* result count)) 
(the fixnum (- count 1)))))) 
(iter 1 n)))
Multi-Paradigms: Functional 
Lambda(λ) 
((lambda (x y) (+ x y)) 1 2) => 3 
Map 
(map 'list #'(lambda (x) (1+ x)) (list 0 1 2 3)) => (1 2 3 4) 
Filter 
(remove-if-not #'oddp (list 1 2 3 4 5 6)) => (1 3 5) 
Fold(foldr in ML) 
(reduce #'+ (list 1 2 3 4 5)) => 15 
Curried Function, Lazy Evaluation, and more...
Multi-Paradigms: Imperative 
Common Lisp does provide imperative operators 
like: 
(setf x 10) ⇔ x := 10 
And for functional functions, Common Lisp also 
provides their ‘destructive’ version: 
map <-> map-into 
filter(remove-if-not) <-> delete-if-not 
And even more: goto, for, while...
Multi-Paradigms: OOP 
● Common Lisp has its own implementation for object 
oriented programming, which is called CLOS. 
● Unlike Java or C++, Common Lisp uses an approach 
called Generic Function instead of Message Passing. 
● Basically, all the methods belongs to generic function 
instead of a specific class. 
● For example, if there's a human class and there's a 
method called speak, then I create an instance of human 
called 'me': 
o In message passing style-> me.speak("Hello") 
o In generic function style-> speak(me, "Hello")
Multi-Paradigms: OOP
Multi-Paradigms: OOP 
A 'men' will have different behavior. 
It’s called method combination.
What Makes Lisp Special? 
1. S-Expression 
1. Macro
S-Expression 
In Common Lisp, a s-exp would be like: 
s-exp : (op s-exp1 s-exp2 ...) 
op: a function | a macro | a special form 
And interestingly, a s-exp could be ‘made’ like this: 
(cons 1 2) => (1 . 2) 
(cons 1 (cons 2 nil)) => (1 . (2 . nil)) => (1 2) 
(cons ‘+ (cons 1 (cons 2 nil))) => (+ 1 2) 
(eval (cons ‘+ (cons 1 (cons 2 nil)))) => 3
S-Expression 
A s-exp looks like a linked list but actually a tree. 
(car (list ‘+ 1 2)) => ‘+ 
(cdr (list ‘+ 1 2)) => (1 2) 
+ 
1 
2 nil 
Writing s-expressions is actually writing the 
Abstract Syntax Tree(AST).
S-Expression: Benefits 
1. There will be no lexical analysis because 
all the codes already are the AST. 
2. There will be no need to worry about the 
Operator Precedence. 
3. Very convenient to represent data 
structures like trees and graphs.
Macro: 
Why Lisp is Called 
Programmable Programming Language? 
● Unlike functions, macros will be expanded 
first before evaluated; 
● After expanding finished, the whole s-expression 
generated by macro will be 
evaluated; 
● So a macro is actually a function that 
transforms arguments to s-expressions.
Macro: A Simple Example 
In this case, it acts like a inline function.
Macro: 
A Real (but a little silly) Example 
Macros can do something that a function can never do.
Macro: A Real Example 
Macros can do something that a function can never do.
Macro: Define New Syntax
Macro: Even Let Evaluation 
Happens During ‘Compiling’ Time 
As mentioned before, a macro will be expanded before 
evaluated -- even before compiled. 
‘Counting how many numbers’ 
happens before run time.
Lisp: 
An ‘Edge’ of Programming Languages 
C++, Java ... Python, Ruby … ML, Haskell 
C Lisp
We toast the Lisp programmer who pens 
his thoughts within nests of parentheses. 
-- Alan J. Perlis 
<SICP>’s foreword 
Thanks for watching!

More Related Content

What's hot

Introduction to Programming in LISP
Introduction to Programming in LISPIntroduction to Programming in LISP
Introduction to Programming in LISPKnoldus Inc.
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming LangugeYaser Jaradeh
 
Real World Haskell: Lecture 7
Real World Haskell: Lecture 7Real World Haskell: Lecture 7
Real World Haskell: Lecture 7Bryan O'Sullivan
 
BayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore HaskellBayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore HaskellBryan O'Sullivan
 
Practical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan HodorogPractical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan Hodorog3Pillar Global
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Piotr Paradziński
 
Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python ProgrammersVsevolod Dyomkin
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellBryan O'Sullivan
 
Real World Haskell: Lecture 1
Real World Haskell: Lecture 1Real World Haskell: Lecture 1
Real World Haskell: Lecture 1Bryan O'Sullivan
 
Logic Programming and Prolog
Logic Programming and PrologLogic Programming and Prolog
Logic Programming and PrologSadegh Dorri N.
 
Introduction to Functional Languages
Introduction to Functional LanguagesIntroduction to Functional Languages
Introduction to Functional Languagessuthi
 
Scheme Programming Language
Scheme Programming LanguageScheme Programming Language
Scheme Programming LanguageReham AlBlehid
 
Contravariant functors in scala
Contravariant functors in scalaContravariant functors in scala
Contravariant functors in scalaPiotr Paradziński
 

What's hot (19)

Introduction to Programming in LISP
Introduction to Programming in LISPIntroduction to Programming in LISP
Introduction to Programming in LISP
 
Lisp
LispLisp
Lisp
 
(Ai lisp)
(Ai lisp)(Ai lisp)
(Ai lisp)
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming Languge
 
Lisp
LispLisp
Lisp
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
 
LISP: Input And Output
LISP: Input And OutputLISP: Input And Output
LISP: Input And Output
 
Real World Haskell: Lecture 7
Real World Haskell: Lecture 7Real World Haskell: Lecture 7
Real World Haskell: Lecture 7
 
BayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore HaskellBayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore Haskell
 
Practical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan HodorogPractical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan Hodorog
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...
 
Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python Programmers
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World Haskell
 
Real World Haskell: Lecture 1
Real World Haskell: Lecture 1Real World Haskell: Lecture 1
Real World Haskell: Lecture 1
 
Logic Programming and Prolog
Logic Programming and PrologLogic Programming and Prolog
Logic Programming and Prolog
 
Introduction to Functional Languages
Introduction to Functional LanguagesIntroduction to Functional Languages
Introduction to Functional Languages
 
Scheme Programming Language
Scheme Programming LanguageScheme Programming Language
Scheme Programming Language
 
Contravariant functors in scala
Contravariant functors in scalaContravariant functors in scala
Contravariant functors in scala
 

Viewers also liked

LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)wahab khan
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog LanguageREHMAT ULLAH
 
Pathfinding algorithms
Pathfinding algorithmsPathfinding algorithms
Pathfinding algorithmsDimos Raptis
 
Artificial Intelligence Algorithms
Artificial Intelligence AlgorithmsArtificial Intelligence Algorithms
Artificial Intelligence AlgorithmsIOSR Journals
 
Redesigning Common Lisp
Redesigning Common LispRedesigning Common Lisp
Redesigning Common Lispfukamachi
 
Digital image processing
Digital image processingDigital image processing
Digital image processingDeevena Dayaal
 
Image processing1 introduction
Image processing1 introductionImage processing1 introduction
Image processing1 introductionPreeti Gupta
 
Digital Image Processing: An Introduction
Digital Image Processing: An IntroductionDigital Image Processing: An Introduction
Digital Image Processing: An IntroductionMostafa G. M. Mostafa
 
Lecture 11 Informed Search
Lecture 11 Informed SearchLecture 11 Informed Search
Lecture 11 Informed SearchHema Kashyap
 
The type writer
The type writerThe type writer
The type writerbsiegmund
 
Introduccion a los lenguajes de programacion para Inteligencia Artificial
Introduccion a los lenguajes de programacion para Inteligencia ArtificialIntroduccion a los lenguajes de programacion para Inteligencia Artificial
Introduccion a los lenguajes de programacion para Inteligencia ArtificialBrian Pando
 
Proyecto Areas Inteligencia Artificial Javier Garcia
Proyecto Areas Inteligencia Artificial Javier GarciaProyecto Areas Inteligencia Artificial Javier Garcia
Proyecto Areas Inteligencia Artificial Javier GarciaJavier García García
 
Lecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmLecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmHema Kashyap
 
Tape recorder - by Ema
Tape recorder - by EmaTape recorder - by Ema
Tape recorder - by EmaNarandaIva
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image ProcessingReshma KC
 

Viewers also liked (20)

LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)
 
LISP:Program structure in lisp
LISP:Program structure in lispLISP:Program structure in lisp
LISP:Program structure in lisp
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog Language
 
Prolog basics
Prolog basicsProlog basics
Prolog basics
 
PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
 
Pathfinding algorithms
Pathfinding algorithmsPathfinding algorithms
Pathfinding algorithms
 
Artificial Intelligence Algorithms
Artificial Intelligence AlgorithmsArtificial Intelligence Algorithms
Artificial Intelligence Algorithms
 
02-Unidad 1 Generalidades de la Inteligencia Artificial
02-Unidad 1 Generalidades de la Inteligencia Artificial02-Unidad 1 Generalidades de la Inteligencia Artificial
02-Unidad 1 Generalidades de la Inteligencia Artificial
 
Redesigning Common Lisp
Redesigning Common LispRedesigning Common Lisp
Redesigning Common Lisp
 
Digital image processing
Digital image processingDigital image processing
Digital image processing
 
Lisp
LispLisp
Lisp
 
Image processing1 introduction
Image processing1 introductionImage processing1 introduction
Image processing1 introduction
 
Digital Image Processing: An Introduction
Digital Image Processing: An IntroductionDigital Image Processing: An Introduction
Digital Image Processing: An Introduction
 
Lecture 11 Informed Search
Lecture 11 Informed SearchLecture 11 Informed Search
Lecture 11 Informed Search
 
The type writer
The type writerThe type writer
The type writer
 
Introduccion a los lenguajes de programacion para Inteligencia Artificial
Introduccion a los lenguajes de programacion para Inteligencia ArtificialIntroduccion a los lenguajes de programacion para Inteligencia Artificial
Introduccion a los lenguajes de programacion para Inteligencia Artificial
 
Proyecto Areas Inteligencia Artificial Javier Garcia
Proyecto Areas Inteligencia Artificial Javier GarciaProyecto Areas Inteligencia Artificial Javier Garcia
Proyecto Areas Inteligencia Artificial Javier Garcia
 
Lecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmLecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithm
 
Tape recorder - by Ema
Tape recorder - by EmaTape recorder - by Ema
Tape recorder - by Ema
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 

Similar to A brief introduction to lisp language

LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийSigma Software
 
Introduction to Functional Programming with Clojure
Introduction to Functional Programming with ClojureIntroduction to Functional Programming with Clojure
Introduction to Functional Programming with ClojureWilton Silva
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To LispLISP Content
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and FuturePushkar Kulkarni
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present FutureIndicThreads
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxprakashvs7
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2callroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.pptcallroom
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmersamiable_indian
 

Similar to A brief introduction to lisp language (20)

LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола Мозговий
 
Clojure intro
Clojure introClojure intro
Clojure intro
 
Introduction to Functional Programming with Clojure
Introduction to Functional Programming with ClojureIntroduction to Functional Programming with Clojure
Introduction to Functional Programming with Clojure
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and Future
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 
test ppt
test ppttest ppt
test ppt
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt21
ppt21ppt21
ppt21
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt17
ppt17ppt17
ppt17
 
ppt30
ppt30ppt30
ppt30
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
 
ppt18
ppt18ppt18
ppt18
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
 

Recently uploaded

Call Girls in Kalyan Vihar Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Kalyan Vihar Delhi 💯 Call Us 🔝8264348440🔝Call Girls in Kalyan Vihar Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Kalyan Vihar Delhi 💯 Call Us 🔝8264348440🔝soniya singh
 
call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..nishakur201
 
Lilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptxLilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptxABMWeaklings
 
Cheap Rate ➥8448380779 ▻Call Girls In Mg Road Gurgaon
Cheap Rate ➥8448380779 ▻Call Girls In Mg Road GurgaonCheap Rate ➥8448380779 ▻Call Girls In Mg Road Gurgaon
Cheap Rate ➥8448380779 ▻Call Girls In Mg Road GurgaonDelhi Call girls
 
Postal Ballot procedure for employees to utilise
Postal Ballot procedure for employees to utilisePostal Ballot procedure for employees to utilise
Postal Ballot procedure for employees to utiliseccsubcollector
 
Dhule Call Girls #9907093804 Contact Number Escorts Service Dhule
Dhule Call Girls #9907093804 Contact Number Escorts Service DhuleDhule Call Girls #9907093804 Contact Number Escorts Service Dhule
Dhule Call Girls #9907093804 Contact Number Escorts Service Dhulesrsj9000
 
REFLECTIONS Newsletter Jan-Jul 2024.pdf.pdf
REFLECTIONS Newsletter Jan-Jul 2024.pdf.pdfREFLECTIONS Newsletter Jan-Jul 2024.pdf.pdf
REFLECTIONS Newsletter Jan-Jul 2024.pdf.pdfssusere8ea60
 
social media chat application main ppt.pptx
social media chat application main ppt.pptxsocial media chat application main ppt.pptx
social media chat application main ppt.pptxsprasad829829
 
Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666nishakur201
 
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdf
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdfBreath, Brain & Beyond_A Holistic Approach to Peak Performance.pdf
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdfJess Walker
 
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...anilsa9823
 
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female serviceanilsa9823
 
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...CIOWomenMagazine
 
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual serviceanilsa9823
 
The Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by MindbrushThe Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by MindbrushShivain97
 
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ EscortsDelhi Escorts Service
 
办理西悉尼大学毕业证成绩单、制作假文凭
办理西悉尼大学毕业证成绩单、制作假文凭办理西悉尼大学毕业证成绩单、制作假文凭
办理西悉尼大学毕业证成绩单、制作假文凭o8wvnojp
 
Reinventing Corporate Philanthropy_ Strategies for Meaningful Impact by Leko ...
Reinventing Corporate Philanthropy_ Strategies for Meaningful Impact by Leko ...Reinventing Corporate Philanthropy_ Strategies for Meaningful Impact by Leko ...
Reinventing Corporate Philanthropy_ Strategies for Meaningful Impact by Leko ...Leko Durda
 
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝soniya singh
 

Recently uploaded (20)

Call Girls in Kalyan Vihar Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Kalyan Vihar Delhi 💯 Call Us 🔝8264348440🔝Call Girls in Kalyan Vihar Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Kalyan Vihar Delhi 💯 Call Us 🔝8264348440🔝
 
call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..
 
Lilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptxLilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptx
 
Cheap Rate ➥8448380779 ▻Call Girls In Mg Road Gurgaon
Cheap Rate ➥8448380779 ▻Call Girls In Mg Road GurgaonCheap Rate ➥8448380779 ▻Call Girls In Mg Road Gurgaon
Cheap Rate ➥8448380779 ▻Call Girls In Mg Road Gurgaon
 
Postal Ballot procedure for employees to utilise
Postal Ballot procedure for employees to utilisePostal Ballot procedure for employees to utilise
Postal Ballot procedure for employees to utilise
 
Dhule Call Girls #9907093804 Contact Number Escorts Service Dhule
Dhule Call Girls #9907093804 Contact Number Escorts Service DhuleDhule Call Girls #9907093804 Contact Number Escorts Service Dhule
Dhule Call Girls #9907093804 Contact Number Escorts Service Dhule
 
REFLECTIONS Newsletter Jan-Jul 2024.pdf.pdf
REFLECTIONS Newsletter Jan-Jul 2024.pdf.pdfREFLECTIONS Newsletter Jan-Jul 2024.pdf.pdf
REFLECTIONS Newsletter Jan-Jul 2024.pdf.pdf
 
social media chat application main ppt.pptx
social media chat application main ppt.pptxsocial media chat application main ppt.pptx
social media chat application main ppt.pptx
 
Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666
 
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdf
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdfBreath, Brain & Beyond_A Holistic Approach to Peak Performance.pdf
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdf
 
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
 
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
 
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...
 
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
 
The Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by MindbrushThe Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by Mindbrush
 
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
 
办理西悉尼大学毕业证成绩单、制作假文凭
办理西悉尼大学毕业证成绩单、制作假文凭办理西悉尼大学毕业证成绩单、制作假文凭
办理西悉尼大学毕业证成绩单、制作假文凭
 
Reinventing Corporate Philanthropy_ Strategies for Meaningful Impact by Leko ...
Reinventing Corporate Philanthropy_ Strategies for Meaningful Impact by Leko ...Reinventing Corporate Philanthropy_ Strategies for Meaningful Impact by Leko ...
Reinventing Corporate Philanthropy_ Strategies for Meaningful Impact by Leko ...
 
escort service sasti (*~Call Girls in Paschim Vihar Metro❤️9953056974
escort service  sasti (*~Call Girls in Paschim Vihar Metro❤️9953056974escort service  sasti (*~Call Girls in Paschim Vihar Metro❤️9953056974
escort service sasti (*~Call Girls in Paschim Vihar Metro❤️9953056974
 
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝
 

A brief introduction to lisp language

  • 1. A Brief Introduction to Lisp Language Tianyu Gu tigu1400@student.miun.se
  • 2. A Brief History ● Originally specified in 1958, Lisp is the second-oldest high-level programming language in widespread use today; only Fortran is older (by one year). ● Lisp stands for LISt Processing(while Fortran stands for FORmula TRANslator). ● 1958 ~ 1980: Various dialects and systems, MacLisp, InterLisp, and Lisp Machines. ● 1975 ~ 1980: Scheme, the first dialect choosing lexical scope, developed in MIT. ● 1980 ~ 1990: Common Lisp, an industry-level language, published in ANSI standard. ● 1990 ~ Now: Various implementation for Common Lisp and Scheme; More 3rd party libraries; A new dialect Clojure.
  • 3. First Impression // C Code int factorial(int n){ if(n==0) return 1; else return n * factorial(n-1); } ;; Common Lisp Code (defun factorial (n) (if (= n 0) 1 (* n (factorial (- n 1)))))
  • 4. First Impression: Evolution // C code, using tail recursion int factorial_helper(int result, int count){ if(count == 0) return result; else return factorial_helper(result*count, count-1); } int factorial(int n){ return factorial_helper(1, n); } ;; Common Lisp code, using tail recursion (defun factorial (n) (declare (optimize (speed 3))) (labels ((iter (result count) (if (= count 0) result (iter (* result count) (1- count))))) (iter 1 n)))
  • 5. First Impression: Final 'Product' ;;;; can even use a function called ‘disassemble’ ;;;; to check the assemble code. (defun factorial (n) (declare (optimize (speed 3))) (labels ((iter (result count) (declare (type fixnum result count)) (if (= count 0) result (iter (the fixnum (* result count)) (the fixnum (- count 1)))))) (iter 1 n)))
  • 6. Multi-Paradigms: Functional Lambda(λ) ((lambda (x y) (+ x y)) 1 2) => 3 Map (map 'list #'(lambda (x) (1+ x)) (list 0 1 2 3)) => (1 2 3 4) Filter (remove-if-not #'oddp (list 1 2 3 4 5 6)) => (1 3 5) Fold(foldr in ML) (reduce #'+ (list 1 2 3 4 5)) => 15 Curried Function, Lazy Evaluation, and more...
  • 7. Multi-Paradigms: Imperative Common Lisp does provide imperative operators like: (setf x 10) ⇔ x := 10 And for functional functions, Common Lisp also provides their ‘destructive’ version: map <-> map-into filter(remove-if-not) <-> delete-if-not And even more: goto, for, while...
  • 8. Multi-Paradigms: OOP ● Common Lisp has its own implementation for object oriented programming, which is called CLOS. ● Unlike Java or C++, Common Lisp uses an approach called Generic Function instead of Message Passing. ● Basically, all the methods belongs to generic function instead of a specific class. ● For example, if there's a human class and there's a method called speak, then I create an instance of human called 'me': o In message passing style-> me.speak("Hello") o In generic function style-> speak(me, "Hello")
  • 10. Multi-Paradigms: OOP A 'men' will have different behavior. It’s called method combination.
  • 11. What Makes Lisp Special? 1. S-Expression 1. Macro
  • 12. S-Expression In Common Lisp, a s-exp would be like: s-exp : (op s-exp1 s-exp2 ...) op: a function | a macro | a special form And interestingly, a s-exp could be ‘made’ like this: (cons 1 2) => (1 . 2) (cons 1 (cons 2 nil)) => (1 . (2 . nil)) => (1 2) (cons ‘+ (cons 1 (cons 2 nil))) => (+ 1 2) (eval (cons ‘+ (cons 1 (cons 2 nil)))) => 3
  • 13. S-Expression A s-exp looks like a linked list but actually a tree. (car (list ‘+ 1 2)) => ‘+ (cdr (list ‘+ 1 2)) => (1 2) + 1 2 nil Writing s-expressions is actually writing the Abstract Syntax Tree(AST).
  • 14. S-Expression: Benefits 1. There will be no lexical analysis because all the codes already are the AST. 2. There will be no need to worry about the Operator Precedence. 3. Very convenient to represent data structures like trees and graphs.
  • 15. Macro: Why Lisp is Called Programmable Programming Language? ● Unlike functions, macros will be expanded first before evaluated; ● After expanding finished, the whole s-expression generated by macro will be evaluated; ● So a macro is actually a function that transforms arguments to s-expressions.
  • 16. Macro: A Simple Example In this case, it acts like a inline function.
  • 17. Macro: A Real (but a little silly) Example Macros can do something that a function can never do.
  • 18. Macro: A Real Example Macros can do something that a function can never do.
  • 20. Macro: Even Let Evaluation Happens During ‘Compiling’ Time As mentioned before, a macro will be expanded before evaluated -- even before compiled. ‘Counting how many numbers’ happens before run time.
  • 21. Lisp: An ‘Edge’ of Programming Languages C++, Java ... Python, Ruby … ML, Haskell C Lisp
  • 22. We toast the Lisp programmer who pens his thoughts within nests of parentheses. -- Alan J. Perlis <SICP>’s foreword Thanks for watching!

Editor's Notes

  1. Dynamic but Strong Type