Skip to content

Instantly share code, notes, and snippets.

@ProfAvery
Last active October 8, 2024 17:54
Show Gist options
  • Select an option

  • Save ProfAvery/bd71f37e6da556f4783ec6f6fa768614 to your computer and use it in GitHub Desktop.

Select an option

Save ProfAvery/bd71f37e6da556f4783ec6f6fa768614 to your computer and use it in GitHub Desktop.
California State University, Fullerton - CPSC 439 - Exercise 8.10 in Scheme
(define PAIR cons)
(define HEAD car)
(define TAIL cdr)
(define ISEMPTY null?)
(define reverse
(lambda (l result)
(if (ISEMPTY l)
result
(reverse (TAIL l) (PAIR (HEAD l) result)))))
(define zip
(lambda (i l)
(define z
(lambda (i l result)
(if (ISEMPTY i)
(reverse result '())
(z (TAIL i) (TAIL l) (PAIR (PAIR (HEAD i) (HEAD l)) result)))))
(z i l '())))
(zip '(1 2 3) '(4 5 6))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment