8.9.900
#lang racket ;; this code defines the sim-VVQS5 language as a module (module sim-VVQS5 racket (provide [rename-out (#%lam-app #%app) (my-let let) #;(my-if if)] #%module-begin #%datum + - * / = equal? <= => if else true false) (define-syntax (#%lam-app stx) (syntax-case stx (=> if else) [(_ (args ...) => body) #'(lambda (args ...) body)] [(_ e1 if e2 else e3) #'(if e2 e1 e3)] [(_ e ...) #'(#%app e ...)])) ) ;; this module uses the sim-VVQS5 language. That is, its ;; contents are written *in* the sim-VVQS5 language. ;; the only edits you should make are inside this module: (module my-mod1 (submod ".." sim-VVQS5) 1234 4567 {+ 4 5} {34 if true else 39} ;; exercise 0: write a function that adds one to a number. ;; exercise 1: combining the definition and application forms, ;; apply the function that adds one to a number to the number 17. ;; thought exercise: does running this program "give a name to a value" anywhere? ;; if so, what name and what value? ;; exercise 2: write a function that accepts a function 'h' and applies ;; it to 8. ;; exercise 3: combining the definition and application forms, ;; apply the function that applies its argument to 8 to the function ;; that adds one to a number. ;; thought exercise: does running this program "give a name to a value" ;; anywhere? if so, what name(s) and what value(s)? ;; exercise 4 (a bit harder): write a function that performs function composition: ;; that is, it accepts functions named 'f' and 'g' and returns a new ;; function of one argument that applies first 'g' and then 'f' to its ;; argument ;; exercise 5 (harder): Write a program that gives the name "compose" to ;; the function defined in the previous exercise, gives the name "add1" to ;; the function that adds one, and then gives the name "add2" to the composition ;; of add1 and add1, and finally applies this add2 function to 99. ) ;; this code actually invokes the 'my-mod1 module, so that the ;; code runs. (require 'my-mod1)