|
|
|
Part 2 Summer 2014 Web.pdf
Part_2_Summer_2014_Web.pdf
Showing 52-53 out of 53
Part 2 Summer 2014 Web.pdf-Part II: Functional Pro...
Part_2_Summer_2014_Web.pdf-Part II: Functional Programming with LISP
Part 2 Summer 2014 Web.pdf-Part II:...
Part_2_Summer_2014_Web.pdf-Part II: Functional Programming with LISP
Page 52
52
103
Example
•
The
sort
function takes a comparison operator as an
argument:
(
sort
(
list
5 2 6 3 1 4) #'>)
; Sorts the list using the > function
; as the comparison operator.
; Returns (6 5 4 3 2 1).
104
Example
•
Write a function testing if a list is sorted.
(
Defun
issorted (lst)
(setf lst1 (copy-list lst))
(setf lst2) (sort lst #’<))
(equal lst lst1)) ; or (equal lst2 lst1))
Page 53
53
105
Example
•
Write a function testing if a list is palindrome.
(
Defun
ispalindrome (lst)
(equal lst (reverse lst))
)
106
Bibliography
1.
Paul Graham, ANSI Common Lisp, Prentice Hall,
1996.
2.
Guy L. Steele, Jr., An overview of COMMON LISP,
Proceedings of the 1982 ACM symposium on LISP
and functional programming.
Ace your assessments! Get Better Grades
Browse thousands of Study Materials & Solutions from your Favorite Schools
Concordia University
Concordia_University
School:
Principles_Of_Programming_Lang
Course:
Introducing Study Plan
Using AI Tools to Help you understand and remember your course concepts better and faster than any other resource.
Find the best videos to learn every concept in that course from Youtube and Tiktok without searching.
Save All Relavent Videos & Materials and access anytime and anywhere
Prepare Smart and Guarantee better grades
Students also viewed documents
lab 18.docx
lab_18.docx
Course
Course
3
Module5QuizSTA2023.d...
Module5QuizSTA2023.docx.docx
Course
Course
10
Week 7 Test Math302....
Week_7_Test_Math302.docx.docx
Course
Course
30
Chapter 1 Assigment ...
Chapter_1_Assigment_Questions.docx.docx
Course
Course
5
Week 4 tests.docx.do...
Week_4_tests.docx.docx
Course
Course
23
Week 6 tests.docx.do...
Week_6_tests.docx.docx
Course
Course
106