Part 2 Summer 2014 Web.pdf-Part II: Func...
Part_2_Summer_2014_Web.pdf-Part II: Functional Programming with LISP
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:
Great resource for chem class. Had all the past labs and assignments
Leland P.
Santa Clara University
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