Blob


1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #reader(lib "htdp-intermediate-reader.ss" "lang")((modname 19.1.4) (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 (define (squared>? x c)
5 (> (* x x) c))
7 ;filter : predicate list-of-numbers
8 ;Filters out all numbers in a-lon where the predicate of the number evaluates to false. Retains all numbers that evaluate to true.
9 (define (filter predicate a-lon)
10 (cond
11 [(empty? a-lon) empty]
12 [(predicate (first a-lon)) (cons (first a-lon) (filter predicate (rest a-lon)))]
13 [else (filter predicate (rest a-lon))]))
15 (filter squared>? '(5 6 7 1 3 5 0 9 3 4 2))