Created
November 15, 2013 23:37
-
-
Save StasisPod/7493602 to your computer and use it in GitHub Desktop.
This function returns all notes that end in the first 10 seconds.
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
;; a note is (make-note note-num frames frames) | |
(define-struct note (pitch time duration)) | |
;; number -> number | |
;; converts seconds to frames | |
(define (s f) | |
(* 44100 f)) | |
(check-expect (s 10) 441000) | |
;; list-of-notes -> list-of-notes | |
;; returns all notes that end in first 10 sec | |
(define (ten-sec l) | |
(cond [(empty? l) empty] | |
[(<= (+ (note-duration (first l)) (note-time (first l))) | |
(s 10)) | |
(cons (first l) (ten-sec (rest l)))] | |
[else (ten-sec (rest l))])) | |
(check-expect (ten-sec | |
(cons (make-note 60 4410000 25) | |
(cons (make-note 60 44000 25) | |
empty))) | |
(cons (make-note 60 44000 25) | |
empty)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment