-
Notifications
You must be signed in to change notification settings - Fork 0
/
244.rkt
34 lines (26 loc) · 948 Bytes
/
244.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-intermediate-reader.ss" "lang")((modname 244ex) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
;; Exercise 244
;; ------------
;; Argue why the following sentences are now legal:
;;
;; (define (f1 x) (x 10))
;;
;; (define (f2 x) (x f2)) ; how is this lega??
;;
;; (define (f3 x y) (x 'a y 'b))
;;
;; Explain your reasoning.
;; -----------------------------------------------------------------------------
; ---
(define (f1 x) (x 10))
(check-expect (f1 identity) 10)
(check-expect (f1 odd?) #false)
; ---
(define (f2 x) (x f2))
; x can just be a function that consumes a function (e.g. f2)
; ---
(define (f3 x y) (x 'a y 'b))
(check-expect (f3 list 'c) (list 'a 'c 'b))
; ---