Last active
October 8, 2024 17:54
-
-
Save ProfAvery/bd71f37e6da556f4783ec6f6fa768614 to your computer and use it in GitHub Desktop.
California State University, Fullerton - CPSC 439 - Exercise 8.10 in Scheme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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