Created
November 25, 2013 18:35
-
-
Save JonTanS/7646272 to your computer and use it in GitHub Desktop.
Practice 1
This file contains 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
;list number -> list | |
;given a list and number, returns a list length of the given number. The length of the list will always be greater than the number. | |
(define (numlist litt number) | |
(cond [(= 0 number) empty] | |
[else (cons (first litt) (numlist (rest litt) (- number 1)))])) | |
(check-expect (numlist (list 1 2 3 4 5) 2) (list 1 2)) | |
(check-expect (numlist (list "cat" "dog" "chicken") 3) (list "cat" "dog" "chicken")) | |
(check-expect (numlist (list 1 2 3 4 1) 0) empty) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment