SlideShare a Scribd company logo
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

PPTX
Radix Sort
PDF
Data Structure Radix Sort
PDF
201801 CSE240 Lecture 17
PDF
201801 CSE240 Lecture 07
PDF
201707 SER332 Lecture 26
PDF
201707 SER332 Lecture 12
PDF
201801 CSE240 Lecture 01
PPTX
1_Introduction_to_R - disease modeling.pptx
Radix Sort
Data Structure Radix Sort
201801 CSE240 Lecture 17
201801 CSE240 Lecture 07
201707 SER332 Lecture 26
201707 SER332 Lecture 12
201801 CSE240 Lecture 01
1_Introduction_to_R - disease modeling.pptx

Similar to 201801 CSE240 Lecture 16 (20)

PDF
201801 CSE240 Lecture 02
PDF
Dynamic Language Embedding With Homogeneous Tool Support
PPTX
C++Object oriented Programming with C++.pptx
PPTX
PDF
201707 SER332 Lecture 15
PDF
R programmingmilano
PDF
KernelF: a functional core for domain-specific languages in JetBrains MPS
PDF
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
PPTX
Programming with R in Big Data Analytics
PDF
201801 CSE240 Lecture 18
PDF
201505 CSE340 Lecture 05
PDF
201801 CSE240 Lecture 06
PDF
Building DSLs On CLR and DLR (Microsoft.NET)
PDF
Pattern-Based Semantic Composition of Optimal Process Service Plans with ODERU
PDF
Indexing Complex PostgreSQL Data Types
PDF
201707 SER332 Lecture 05
PPTX
Scheme language
PDF
Arrays in C
PDF
Data Structures and Algorithms (DSA) in C
PPTX
Introduction to R for Learning Analytics Researchers
201801 CSE240 Lecture 02
Dynamic Language Embedding With Homogeneous Tool Support
C++Object oriented Programming with C++.pptx
201707 SER332 Lecture 15
R programmingmilano
KernelF: a functional core for domain-specific languages in JetBrains MPS
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
Programming with R in Big Data Analytics
201801 CSE240 Lecture 18
201505 CSE340 Lecture 05
201801 CSE240 Lecture 06
Building DSLs On CLR and DLR (Microsoft.NET)
Pattern-Based Semantic Composition of Optimal Process Service Plans with ODERU
Indexing Complex PostgreSQL Data Types
201707 SER332 Lecture 05
Scheme language
Arrays in C
Data Structures and Algorithms (DSA) in C
Introduction to R for Learning Analytics Researchers
Ad

More from Javier Gonzalez-Sanchez (20)

PDF
201804 SER332 Lecture 01
PDF
201801 SER332 Lecture 03
PDF
201801 SER332 Lecture 04
PDF
201801 SER332 Lecture 02
PDF
201801 CSE240 Lecture 26
PDF
201801 CSE240 Lecture 25
PDF
201801 CSE240 Lecture 24
PDF
201801 CSE240 Lecture 23
PDF
201801 CSE240 Lecture 22
PDF
201801 CSE240 Lecture 21
PDF
201801 CSE240 Lecture 20
PDF
201801 CSE240 Lecture 19
PDF
201801 CSE240 Lecture 15
PDF
201801 CSE240 Lecture 14
PDF
201801 CSE240 Lecture 13
PDF
201801 CSE240 Lecture 12
PDF
201801 CSE240 Lecture 11
PDF
201801 CSE240 Lecture 10
PDF
201801 CSE240 Lecture 09
PDF
201801 CSE240 Lecture 08
201804 SER332 Lecture 01
201801 SER332 Lecture 03
201801 SER332 Lecture 04
201801 SER332 Lecture 02
201801 CSE240 Lecture 26
201801 CSE240 Lecture 25
201801 CSE240 Lecture 24
201801 CSE240 Lecture 23
201801 CSE240 Lecture 22
201801 CSE240 Lecture 21
201801 CSE240 Lecture 20
201801 CSE240 Lecture 19
201801 CSE240 Lecture 15
201801 CSE240 Lecture 14
201801 CSE240 Lecture 13
201801 CSE240 Lecture 12
201801 CSE240 Lecture 11
201801 CSE240 Lecture 10
201801 CSE240 Lecture 09
201801 CSE240 Lecture 08
Ad

Recently uploaded (20)

PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
System and Network Administration Chapter 2
PDF
medical staffing services at VALiNTRY
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
L1 - Introduction to python Backend.pptx
PDF
Digital Strategies for Manufacturing Companies
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Understanding Forklifts - TECH EHS Solution
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Essential Infomation Tech presentation.pptx
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
System and Network Administration Chapter 2
medical staffing services at VALiNTRY
How to Migrate SBCGlobal Email to Yahoo Easily
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Navsoft: AI-Powered Business Solutions & Custom Software Development
PTS Company Brochure 2025 (1).pdf.......
Odoo POS Development Services by CandidRoot Solutions
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Odoo Companies in India – Driving Business Transformation.pdf
L1 - Introduction to python Backend.pptx
Digital Strategies for Manufacturing Companies
VVF-Customer-Presentation2025-Ver1.9.pptx
Understanding Forklifts - TECH EHS Solution
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
How Creative Agencies Leverage Project Management Software.pdf
Design an Analysis of Algorithms II-SECS-1021-03
Essential Infomation Tech presentation.pptx
How to Choose the Right IT Partner for Your Business in Malaysia
wealthsignaloriginal-com-DS-text-... (1).pdf

201801 CSE240 Lecture 16

  • 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.