Lecture overview -- Keyboard shortcut: 'u'  Previous page: Zipping -- Keyboard shortcut: 'p'  Next page: Currying [Section] -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 2 - Page 31 : 35
Programming Paradigms
Recursion and Higher-order Functions
The zipping function

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/zipping.scmThe function zip.


Expression

Value

(zip cons '(1 2 3) '(a b c))
((1 . a) (2 . b) (3 . c))
(apply string-append
 (zip 
  string-append
  '("Rip" "Rap" "Rup")
  '(", " ", and " "")))
"Rip, Rap, and Rup"
(string-merge 
  '("Rip" "Rap" "Rup") '(", " ", and "))
"Rip, Rap, and Rup"

Examples of zipping. Please notice that (map cons '(1 2 3) '(a b c)) gives the same result as provide that that map accept more than one list. The map in R5RS or R6RS does accept more than one list. If two lists are provided the mapping functions expects two parameters, one from each of the list.