SlideShare a Scribd company logo
CSE240 – Introduction to
Programming Languages
Lecture 20:
Programming with LISP| Data Structures
Javier Gonzalez-Sanchez
javiergs@asu.edu
javiergs.engineering.asu.edu
Office Hours: By appointment
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 2
Data Structures
The only data structure is List
• (quote (hello world 1 2 3))
(HELLO WORLD 1 2 3)
• '(hello world 1 2 3)
(HELLO WORLD 1 2 3)
• (quote (what is (going on) here?))
(WHAT IS (GOING ON) HERE?)
• (quote my-symbol)
MY-SYMBOL
• (quote (+ 4 (* 3 2 9)))
(+ 4 (* 3 2 9))
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 3
Data Structures
• first returns the first item in a list. The old name of first is car (content of
the address).
• rest returns a list consisting of everything but the first item. It does not
damage the original list. The old name of rest is cdr (content of the
decrement register).
• append hooks multiple lists together.
• cons takes an item and a list, and returns a new list consisting of the
old list with the item tacked on the front.
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 4
Data Structures
• ( setf myList '( (A B) C (D) ) )
((A B) C (D))
• (car (car myList) ) ;( first ( first ) )
A
• (cdr( car myList)) ;( last ( first ) )
(B)
• (car (cdr myList)) ;( first ( rest ) )
C
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 5
Data Structures
• ( setf myList2 '(A (B () (C () () )) (D (E () () ) () ) ) )
(A (B NIL (C NIL NIL)) (D (E NIL NIL) NIL))
• (car (car myList2)) ;( first ( first (L))
Error: Cannot take CAR of A.
• (cdr( car myList2)) ;( rest ( first (L))
Error: Cannot take CDR of A.
• (car (cdr myList2)) ;( first ( rest (L))
(B NIL (C NIL NIL))
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 6
Loop (dolist)
• (dolist (x '(a b c d e)) (print x))
A
B
C
D
E
NIL
dolist is an iterator with this format
(dolist (var list-to-iterate-over optional-return-val)
expr1
expr2
…)
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 7
Loop (dolist)
• (defun my-reverse (list)
(let (new-list) ; empty list
(dolist (x list)
(setf new-list (cons x new-list))
)
new-list)
)
MY-REVERSE
• (my-reverse '(a b c d e f g))
(G F E D C B A)
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 8
Loop (dolist)
• (defun my-reverse (list)
(let (new-list) ; empty list
(dolist (x list)
(setf new-list (cons x new-list))
)
new-list)
)
MY-REVERSE
• (my-reverse '(a b c d e f g))
(G F E D C B A)
• (print (first (my-reverse '(a b c d e f g))))
G
• (print (last (my-reverse '(a b c d e f g))))
(A)
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

What's hot

Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
Lukasz Dynowski
 
openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)
openCypher
 
cloud computing training in chennai
cloud computing training in chennaicloud computing training in chennai
cloud computing training in chennai
matrixphagwara
 
6months industrial training in artificial intelligence, jalandhar
6months industrial training in artificial intelligence, jalandhar6months industrial training in artificial intelligence, jalandhar
6months industrial training in artificial intelligence, jalandhar
deepikakaler1
 
cloud computing training in delhi
cloud computing training in delhicloud computing training in delhi
cloud computing training in delhi
matrixphagwara
 
6 weeks summer training in artificial intelligence,jalandhar
6 weeks summer training in artificial intelligence,jalandhar6 weeks summer training in artificial intelligence,jalandhar
6 weeks summer training in artificial intelligence,jalandhar
deepikakaler1
 
Kotlin DSL beats the builder pattern
Kotlin DSL beats the builder patternKotlin DSL beats the builder pattern
Kotlin DSL beats the builder pattern
arild2
 
Forms of Quadratics
Forms of QuadraticsForms of Quadratics
Forms of Quadratics
mrodolewicz
 
ひけらかし会(visualization)
ひけらかし会(visualization)ひけらかし会(visualization)
ひけらかし会(visualization)moai kids
 
Recognize Godzilla
Recognize GodzillaRecognize Godzilla
Recognize Godzilla
隊長 アイパー
 
Bayesian learning
Bayesian learning Bayesian learning
Bayesian learning
EngReads
 
Geographic Information System (May – 2016) [75:25 Pattern | Question Paper]
Geographic Information System (May – 2016) [75:25 Pattern | Question Paper]Geographic Information System (May – 2016) [75:25 Pattern | Question Paper]
Geographic Information System (May – 2016) [75:25 Pattern | Question Paper]
Mumbai B.Sc.IT Study
 
Visualization team presentation
Visualization team presentation Visualization team presentation
Visualization team presentation
madhobilota
 
WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016
WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016
WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016
Penn State University
 
[Question Paper] Computer Graphics (Revised Course) [June / 2016]
[Question Paper] Computer Graphics (Revised Course) [June / 2016][Question Paper] Computer Graphics (Revised Course) [June / 2016]
[Question Paper] Computer Graphics (Revised Course) [June / 2016]
Mumbai B.Sc.IT Study
 

What's hot (18)

Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
 
2
22
2
 
Python Set.pptx
Python Set.pptxPython Set.pptx
Python Set.pptx
 
openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)
 
R
RR
R
 
cloud computing training in chennai
cloud computing training in chennaicloud computing training in chennai
cloud computing training in chennai
 
6months industrial training in artificial intelligence, jalandhar
6months industrial training in artificial intelligence, jalandhar6months industrial training in artificial intelligence, jalandhar
6months industrial training in artificial intelligence, jalandhar
 
cloud computing training in delhi
cloud computing training in delhicloud computing training in delhi
cloud computing training in delhi
 
6 weeks summer training in artificial intelligence,jalandhar
6 weeks summer training in artificial intelligence,jalandhar6 weeks summer training in artificial intelligence,jalandhar
6 weeks summer training in artificial intelligence,jalandhar
 
Kotlin DSL beats the builder pattern
Kotlin DSL beats the builder patternKotlin DSL beats the builder pattern
Kotlin DSL beats the builder pattern
 
Forms of Quadratics
Forms of QuadraticsForms of Quadratics
Forms of Quadratics
 
ひけらかし会(visualization)
ひけらかし会(visualization)ひけらかし会(visualization)
ひけらかし会(visualization)
 
Recognize Godzilla
Recognize GodzillaRecognize Godzilla
Recognize Godzilla
 
Bayesian learning
Bayesian learning Bayesian learning
Bayesian learning
 
Geographic Information System (May – 2016) [75:25 Pattern | Question Paper]
Geographic Information System (May – 2016) [75:25 Pattern | Question Paper]Geographic Information System (May – 2016) [75:25 Pattern | Question Paper]
Geographic Information System (May – 2016) [75:25 Pattern | Question Paper]
 
Visualization team presentation
Visualization team presentation Visualization team presentation
Visualization team presentation
 
WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016
WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016
WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016
 
[Question Paper] Computer Graphics (Revised Course) [June / 2016]
[Question Paper] Computer Graphics (Revised Course) [June / 2016][Question Paper] Computer Graphics (Revised Course) [June / 2016]
[Question Paper] Computer Graphics (Revised Course) [June / 2016]
 

Similar to 201801 CSE240 Lecture 20

201801 CSE240 Lecture 17
201801 CSE240 Lecture 17201801 CSE240 Lecture 17
201801 CSE240 Lecture 17
Javier Gonzalez-Sanchez
 
Recursion and Functional Programming
Recursion and Functional ProgrammingRecursion and Functional Programming
Recursion and Functional Programmingsathish316
 
Scheme 核心概念(一)
Scheme 核心概念(一)Scheme 核心概念(一)
Scheme 核心概念(一)
維然 柯維然
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence)
wahab khan
 
(Ai lisp)
(Ai lisp)(Ai lisp)
(Ai lisp)
Ravi Rao
 
Big datacourse
Big datacourseBig datacourse
Big datacourse
Massimiliano Ruocco
 
Scheme language
Scheme languageScheme language
Scheme language
JITENDRA LENKA
 
Microsoft Word Practice Exercise Set 2
Microsoft Word   Practice Exercise Set 2Microsoft Word   Practice Exercise Set 2
Microsoft Word Practice Exercise Set 2rampan
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Chia-Chi Chang
 
Brief intro to clojure
Brief intro to clojureBrief intro to clojure
Brief intro to clojure
Roy Rutto
 
Add math may june 2016 p1
Add math may june 2016 p1Add math may june 2016 p1
Add math may june 2016 p1
Don Cunningham
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lisp
kyleburton
 
Data analysis with R
Data analysis with RData analysis with R
Data analysis with R
ShareThis
 
Lisp tutorial
Lisp tutorialLisp tutorial
Lisp tutorial
Nilt1234
 
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...
PingCAP
 
dld 01-introduction
dld 01-introductiondld 01-introduction
dld 01-introduction
United International University
 
Functional Programming.pptx
Functional Programming.pptxFunctional Programming.pptx
Functional Programming.pptx
PremBorse1
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
 

Similar to 201801 CSE240 Lecture 20 (20)

201801 CSE240 Lecture 17
201801 CSE240 Lecture 17201801 CSE240 Lecture 17
201801 CSE240 Lecture 17
 
Recursion and Functional Programming
Recursion and Functional ProgrammingRecursion and Functional Programming
Recursion and Functional Programming
 
Scheme 核心概念(一)
Scheme 核心概念(一)Scheme 核心概念(一)
Scheme 核心概念(一)
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence)
 
(Ai lisp)
(Ai lisp)(Ai lisp)
(Ai lisp)
 
Big datacourse
Big datacourseBig datacourse
Big datacourse
 
Scheme language
Scheme languageScheme language
Scheme language
 
Microsoft Word Practice Exercise Set 2
Microsoft Word   Practice Exercise Set 2Microsoft Word   Practice Exercise Set 2
Microsoft Word Practice Exercise Set 2
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)
 
Brief intro to clojure
Brief intro to clojureBrief intro to clojure
Brief intro to clojure
 
Add math may june 2016 p1
Add math may june 2016 p1Add math may june 2016 p1
Add math may june 2016 p1
 
Perm winter school 2014.01.31
Perm winter school 2014.01.31Perm winter school 2014.01.31
Perm winter school 2014.01.31
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lisp
 
Data analysis with R
Data analysis with RData analysis with R
Data analysis with R
 
Lisp tutorial
Lisp tutorialLisp tutorial
Lisp tutorial
 
Ada
AdaAda
Ada
 
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...
 
dld 01-introduction
dld 01-introductiondld 01-introduction
dld 01-introduction
 
Functional Programming.pptx
Functional Programming.pptxFunctional Programming.pptx
Functional Programming.pptx
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 

More from Javier Gonzalez-Sanchez

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

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 19
201801 CSE240 Lecture 19201801 CSE240 Lecture 19
201801 CSE240 Lecture 19
 
201801 CSE240 Lecture 16
201801 CSE240 Lecture 16201801 CSE240 Lecture 16
201801 CSE240 Lecture 16
 
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

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
ayushiqss
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 

Recently uploaded (20)

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 

201801 CSE240 Lecture 20

  • 1. CSE240 – Introduction to Programming Languages Lecture 20: Programming with LISP| Data Structures Javier Gonzalez-Sanchez javiergs@asu.edu javiergs.engineering.asu.edu Office Hours: By appointment
  • 2. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 2 Data Structures The only data structure is List • (quote (hello world 1 2 3)) (HELLO WORLD 1 2 3) • '(hello world 1 2 3) (HELLO WORLD 1 2 3) • (quote (what is (going on) here?)) (WHAT IS (GOING ON) HERE?) • (quote my-symbol) MY-SYMBOL • (quote (+ 4 (* 3 2 9))) (+ 4 (* 3 2 9))
  • 3. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 3 Data Structures • first returns the first item in a list. The old name of first is car (content of the address). • rest returns a list consisting of everything but the first item. It does not damage the original list. The old name of rest is cdr (content of the decrement register). • append hooks multiple lists together. • cons takes an item and a list, and returns a new list consisting of the old list with the item tacked on the front.
  • 4. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 4 Data Structures • ( setf myList '( (A B) C (D) ) ) ((A B) C (D)) • (car (car myList) ) ;( first ( first ) ) A • (cdr( car myList)) ;( last ( first ) ) (B) • (car (cdr myList)) ;( first ( rest ) ) C
  • 5. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 5 Data Structures • ( setf myList2 '(A (B () (C () () )) (D (E () () ) () ) ) ) (A (B NIL (C NIL NIL)) (D (E NIL NIL) NIL)) • (car (car myList2)) ;( first ( first (L)) Error: Cannot take CAR of A. • (cdr( car myList2)) ;( rest ( first (L)) Error: Cannot take CDR of A. • (car (cdr myList2)) ;( first ( rest (L)) (B NIL (C NIL NIL))
  • 6. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 6 Loop (dolist) • (dolist (x '(a b c d e)) (print x)) A B C D E NIL dolist is an iterator with this format (dolist (var list-to-iterate-over optional-return-val) expr1 expr2 …)
  • 7. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 7 Loop (dolist) • (defun my-reverse (list) (let (new-list) ; empty list (dolist (x list) (setf new-list (cons x new-list)) ) new-list) ) MY-REVERSE • (my-reverse '(a b c d e f g)) (G F E D C B A)
  • 8. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 8 Loop (dolist) • (defun my-reverse (list) (let (new-list) ; empty list (dolist (x list) (setf new-list (cons x new-list)) ) new-list) ) MY-REVERSE • (my-reverse '(a b c d e f g)) (G F E D C B A) • (print (first (my-reverse '(a b c d e f g)))) G • (print (last (my-reverse '(a b c d e f g)))) (A)
  • 9. 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.