SlideShare a Scribd company logo
1 of 12
CSE240 – Introduction to
Programming Languages
Lecture 16:
Programming with LISP
Javier Gonzalez-Sanchez
javiergs@asu.edu
javiergs.engineering.asu.edu
Office Hours: By appointment
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 2
Functional Paradigm
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 3
Semantic
Functional Paradigm
Key idea:
Focus on higher level of abstraction
(free from programming details)
Features:
Simpler semantic: no data types, and
a simpler syntax
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 4
Syntax
• Uniform representation of instructions and data using a single general
format– a list.
(functionId param1 param2 param3 ...)
• (+ 3 2 7 9) ; add 3+2+7+9 and return the result
21
• (* 4 2.3) ; multiply 4 by 2.3 and return the result
9.2
• (subseq "Hello, World" 2 9)
"llo, Wo"
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 5
Functional Programming
• Language: we will use LISP (LISt Processing).
• It uses an interpreter.
• Automatic management of memory.
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 6
You need an Interpreter
• LispWork Personal Edition –
http://www.lispworks.com/downloads/index.html
• Compile Lisp Online –
http://rextester.com/l/common_lisp_online_compiler
• Steel Bank Common Lisp –
http://www.sbcl.org/platform-table.html
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 7
Functional Programming
• A program is a set of lists and they are enclosed with parenthesis.
• We use lists to represent functions; in a function the first element of the list is
the id of the function and the rest are parameter(s)
• Whitespace separate function id and parameters
• Examples:
( print "Hello World" )
( + 2 2 )
( sqrt 2 )
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 8
Important Notice !
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 9
Everything is a List
• A function ID (symbol) is a series of characters other than whitespace, parentheses ( ), pound
( # ), quote ( ' ), double-quote ( " ), period ( . ), or back quote ( ` ).
• A function ID (symbol) may not take the form of numbers.
• It's very common for symbols to have hyphens ( - ) or asterisks ( * ) in them.
• There are NOT operators! only functions
• Symbols (function ID) are case-INSENSITIVE.
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 10
Atomic Expressions
• -3
• 2.43
• 123342303923412323411323234012923492341231230234923410239234412
• #C(3.2 2) ; the complex number 3.2 + 2i
• 2/3 ; the fraction 2/3. It is NOT divide 2 by 3
• -3.2e25 ; the number -3.2 x 10^25
• #g ; characters starts with #
• #{
• # ; the character ''
• #tab

• #newline
• 
#space

• #backspace

• #escape
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 11
Atomic Expressions
• "Hello, World!"
• "It's a glorious day."
• "He said "No Way!" and then he left."
• "I think I need a backslash here:  Ah, that was better."
• t ; true
• nil ; false
CSE240 – Introduction to Programming Languages
Javier Gonzalez-Sanchez
javiergs@asu.edu
Fall 2017
Disclaimer. These slides can only be used as study material for the class CSE240 at ASU. They cannot be distributed or used for another purpose.

More Related Content

Similar to Programming with LISP in CSE240

Dynamic Language Embedding With Homogeneous Tool Support
Dynamic Language Embedding With Homogeneous Tool SupportDynamic Language Embedding With Homogeneous Tool Support
Dynamic Language Embedding With Homogeneous Tool SupportLukas Renggli
 
KernelF: a functional core for domain-specific languages in JetBrains MPS
KernelF: a functional core for domain-specific languages in JetBrains MPSKernelF: a functional core for domain-specific languages in JetBrains MPS
KernelF: a functional core for domain-specific languages in JetBrains MPSMikhail Barash
 
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)ruthmcdavitt
 
Programming with R in Big Data Analytics
Programming with R in Big Data AnalyticsProgramming with R in Big Data Analytics
Programming with R in Big Data AnalyticsArchana Gopinath
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Vitaly Baum
 
Pattern-Based Semantic Composition of Optimal Process Service Plans with ODERU
Pattern-Based Semantic Composition of Optimal Process Service Plans with ODERUPattern-Based Semantic Composition of Optimal Process Service Plans with ODERU
Pattern-Based Semantic Composition of Optimal Process Service Plans with ODERULuca Mazzola
 
Indexing Complex PostgreSQL Data Types
Indexing Complex PostgreSQL Data TypesIndexing Complex PostgreSQL Data Types
Indexing Complex PostgreSQL Data TypesJonathan Katz
 
Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersVitomir Kovanovic
 
GR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume LaforgeGR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume LaforgeGR8Conf
 
Angular 2 On Production (IT Talk in Dnipro)
Angular 2 On Production (IT Talk in Dnipro)Angular 2 On Production (IT Talk in Dnipro)
Angular 2 On Production (IT Talk in Dnipro)Oleksandr Tryshchenko
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개Reagan Hwang
 

Similar to Programming with LISP in CSE240 (20)

Dynamic Language Embedding With Homogeneous Tool Support
Dynamic Language Embedding With Homogeneous Tool SupportDynamic Language Embedding With Homogeneous Tool Support
Dynamic Language Embedding With Homogeneous Tool Support
 
c
cc
c
 
201707 SER332 Lecture 15
201707 SER332 Lecture 15  201707 SER332 Lecture 15
201707 SER332 Lecture 15
 
R programmingmilano
R programmingmilanoR programmingmilano
R programmingmilano
 
KernelF: a functional core for domain-specific languages in JetBrains MPS
KernelF: a functional core for domain-specific languages in JetBrains MPSKernelF: a functional core for domain-specific languages in JetBrains MPS
KernelF: a functional core for domain-specific languages in JetBrains MPS
 
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
 
Programming with R in Big Data Analytics
Programming with R in Big Data AnalyticsProgramming with R in Big Data Analytics
Programming with R in Big Data Analytics
 
201801 CSE240 Lecture 18
201801 CSE240 Lecture 18201801 CSE240 Lecture 18
201801 CSE240 Lecture 18
 
201505 CSE340 Lecture 05
201505 CSE340 Lecture 05201505 CSE340 Lecture 05
201505 CSE340 Lecture 05
 
201801 CSE240 Lecture 06
201801 CSE240 Lecture 06201801 CSE240 Lecture 06
201801 CSE240 Lecture 06
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)
 
Pattern-Based Semantic Composition of Optimal Process Service Plans with ODERU
Pattern-Based Semantic Composition of Optimal Process Service Plans with ODERUPattern-Based Semantic Composition of Optimal Process Service Plans with ODERU
Pattern-Based Semantic Composition of Optimal Process Service Plans with ODERU
 
Indexing Complex PostgreSQL Data Types
Indexing Complex PostgreSQL Data TypesIndexing Complex PostgreSQL Data Types
Indexing Complex PostgreSQL Data Types
 
201707 SER332 Lecture 05
201707 SER332 Lecture 05   201707 SER332 Lecture 05
201707 SER332 Lecture 05
 
Scheme language
Scheme languageScheme language
Scheme language
 
Arrays in C
Arrays in CArrays in C
Arrays in C
 
Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics Researchers
 
GR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume LaforgeGR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
 
Angular 2 On Production (IT Talk in Dnipro)
Angular 2 On Production (IT Talk in Dnipro)Angular 2 On Production (IT Talk in Dnipro)
Angular 2 On Production (IT Talk in Dnipro)
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
 

More from Javier Gonzalez-Sanchez (20)

201804 SER332 Lecture 01
201804 SER332 Lecture 01201804 SER332 Lecture 01
201804 SER332 Lecture 01
 
201801 SER332 Lecture 03
201801 SER332 Lecture 03201801 SER332 Lecture 03
201801 SER332 Lecture 03
 
201801 SER332 Lecture 04
201801 SER332 Lecture 04201801 SER332 Lecture 04
201801 SER332 Lecture 04
 
201801 SER332 Lecture 02
201801 SER332 Lecture 02201801 SER332 Lecture 02
201801 SER332 Lecture 02
 
201801 CSE240 Lecture 26
201801 CSE240 Lecture 26201801 CSE240 Lecture 26
201801 CSE240 Lecture 26
 
201801 CSE240 Lecture 25
201801 CSE240 Lecture 25201801 CSE240 Lecture 25
201801 CSE240 Lecture 25
 
201801 CSE240 Lecture 24
201801 CSE240 Lecture 24201801 CSE240 Lecture 24
201801 CSE240 Lecture 24
 
201801 CSE240 Lecture 23
201801 CSE240 Lecture 23201801 CSE240 Lecture 23
201801 CSE240 Lecture 23
 
201801 CSE240 Lecture 22
201801 CSE240 Lecture 22201801 CSE240 Lecture 22
201801 CSE240 Lecture 22
 
201801 CSE240 Lecture 21
201801 CSE240 Lecture 21201801 CSE240 Lecture 21
201801 CSE240 Lecture 21
 
201801 CSE240 Lecture 20
201801 CSE240 Lecture 20201801 CSE240 Lecture 20
201801 CSE240 Lecture 20
 
201801 CSE240 Lecture 19
201801 CSE240 Lecture 19201801 CSE240 Lecture 19
201801 CSE240 Lecture 19
 
201801 CSE240 Lecture 15
201801 CSE240 Lecture 15201801 CSE240 Lecture 15
201801 CSE240 Lecture 15
 
201801 CSE240 Lecture 14
201801 CSE240 Lecture 14201801 CSE240 Lecture 14
201801 CSE240 Lecture 14
 
201801 CSE240 Lecture 13
201801 CSE240 Lecture 13201801 CSE240 Lecture 13
201801 CSE240 Lecture 13
 
201801 CSE240 Lecture 12
201801 CSE240 Lecture 12201801 CSE240 Lecture 12
201801 CSE240 Lecture 12
 
201801 CSE240 Lecture 11
201801 CSE240 Lecture 11201801 CSE240 Lecture 11
201801 CSE240 Lecture 11
 
201801 CSE240 Lecture 10
201801 CSE240 Lecture 10201801 CSE240 Lecture 10
201801 CSE240 Lecture 10
 
201801 CSE240 Lecture 09
201801 CSE240 Lecture 09201801 CSE240 Lecture 09
201801 CSE240 Lecture 09
 
201801 CSE240 Lecture 08
201801 CSE240 Lecture 08201801 CSE240 Lecture 08
201801 CSE240 Lecture 08
 

Recently uploaded

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 

Recently uploaded (20)

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 

Programming with LISP in CSE240

  • 1. CSE240 – Introduction to Programming Languages Lecture 16: Programming with LISP Javier Gonzalez-Sanchez javiergs@asu.edu javiergs.engineering.asu.edu Office Hours: By appointment
  • 2. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 2 Functional Paradigm
  • 3. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 3 Semantic Functional Paradigm Key idea: Focus on higher level of abstraction (free from programming details) Features: Simpler semantic: no data types, and a simpler syntax
  • 4. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 4 Syntax • Uniform representation of instructions and data using a single general format– a list. (functionId param1 param2 param3 ...) • (+ 3 2 7 9) ; add 3+2+7+9 and return the result 21 • (* 4 2.3) ; multiply 4 by 2.3 and return the result 9.2 • (subseq "Hello, World" 2 9) "llo, Wo"
  • 5. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 5 Functional Programming • Language: we will use LISP (LISt Processing). • It uses an interpreter. • Automatic management of memory.
  • 6. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 6 You need an Interpreter • LispWork Personal Edition – http://www.lispworks.com/downloads/index.html • Compile Lisp Online – http://rextester.com/l/common_lisp_online_compiler • Steel Bank Common Lisp – http://www.sbcl.org/platform-table.html
  • 7. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 7 Functional Programming • A program is a set of lists and they are enclosed with parenthesis. • We use lists to represent functions; in a function the first element of the list is the id of the function and the rest are parameter(s) • Whitespace separate function id and parameters • Examples: ( print "Hello World" ) ( + 2 2 ) ( sqrt 2 )
  • 8. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 8 Important Notice !
  • 9. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 9 Everything is a List • A function ID (symbol) is a series of characters other than whitespace, parentheses ( ), pound ( # ), quote ( ' ), double-quote ( " ), period ( . ), or back quote ( ` ). • A function ID (symbol) may not take the form of numbers. • It's very common for symbols to have hyphens ( - ) or asterisks ( * ) in them. • There are NOT operators! only functions • Symbols (function ID) are case-INSENSITIVE.
  • 10. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 10 Atomic Expressions • -3 • 2.43 • 123342303923412323411323234012923492341231230234923410239234412 • #C(3.2 2) ; the complex number 3.2 + 2i • 2/3 ; the fraction 2/3. It is NOT divide 2 by 3 • -3.2e25 ; the number -3.2 x 10^25 • #g ; characters starts with # • #{ • # ; the character '' • #tab
 • #newline • 
#space
 • #backspace
 • #escape
  • 11. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 11 Atomic Expressions • "Hello, World!" • "It's a glorious day." • "He said "No Way!" and then he left." • "I think I need a backslash here: Ah, that was better." • t ; true • nil ; false
  • 12. CSE240 – Introduction to Programming Languages Javier Gonzalez-Sanchez javiergs@asu.edu Fall 2017 Disclaimer. These slides can only be used as study material for the class CSE240 at ASU. They cannot be distributed or used for another purpose.