#lang racket ; downward funarg (define (a x y) ; x is a natural number, y is a list of functions with no args (define z x) (define (f) z) (define (g l) ; evaluates each list element as a function with no args, along with summing (if (empty? l) 0 (+ ((car l)) (g (cdr l))))) (define (b) (define (c) (define (d) (define (e) ; builds list of function references or evaluates list (if (= x 0) (g y) ; evaluate the list (a (sub1 x) (cons f y)))) ; (e)) (d)) (c)) (b)) ; upward funarg (define (h x y) ; x is a natural number, y is a list of functions with no args (define z x) (define (f) z) (define (g l) ; evaluates each list element as a function with no args, along with summing (if (empty? l) 0 (+ ((car l)) (g (cdr l))))) (define (b) (define (c) (define (d) (define (e) ; builds list of function references or evaluates list (if (= x 0) (lambda () (g y)) ; return function to evaluate the list (h (sub1 x) (cons f y)))) ; (e)) (d)) (c)) (b)) (a 5 '()) (h 5 '()) ((h 5 '()))