Blame


1 12687dd9 2023-08-04 jrmu ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 12687dd9 2023-08-04 jrmu ;; about the language level of this file in a form that our tools can easily process.
3 12687dd9 2023-08-04 jrmu #reader(lib "htdp-intermediate-reader.ss" "lang")((modname 19.2.1) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp")))))
4 12687dd9 2023-08-04 jrmu ;filter1 : predicate list-of-numbers
5 12687dd9 2023-08-04 jrmu ;Filters out all numbers in a-lon where the predicate of the number evaluates to false. Retains all numbers that evaluate to true.
6 12687dd9 2023-08-04 jrmu (define (filter1 predicate a-lon t)
7 12687dd9 2023-08-04 jrmu (cond
8 12687dd9 2023-08-04 jrmu [(empty? a-lon) empty]
9 12687dd9 2023-08-04 jrmu [(predicate (first a-lon) t) (cons (first a-lon)
10 12687dd9 2023-08-04 jrmu (filter1 predicate (rest a-lon) t))]
11 12687dd9 2023-08-04 jrmu [else (filter1 predicate (rest a-lon) t)]))