CSC324H5 Lecture Notes - Lecture 2: Tail Call, Call Stack, Functional Programming

59 views3 pages
14 Sep 2017
School
Course

Document Summary

Racket views lists as a recursive data structure. The empty list is a list, represented in racket by () or empty. If lst is a list, and item is a value, then we can create a new list whose first element is item and whose other items are the ones from lst. Racket with the cons function: (cons item my-list). ; list with one element - an item cons d with an empty list (cons 3 empty) ; equivalently, (3 . ; list with two elements (cons 3 (cons (+ 10 2) ())) We call the symbol at the beginning of this expression the quote. Pretty amazingly, you can also use the quote in your code to create lists. This offers a shorter alternative to either cons or list, In pure functional programming, where muta- tion is not allowed, lists are processed by using their recursive structure to write recursive algorithms.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents