大家好,对于学校,我必须创建一个函数,其中 lambda 用作参数
像这样:(string (lambda ...) 5 40)我们必须填写点
这是我们必须重新发明的函数,常规字符串版本
(define (string decoration n r) >string decoration is a function that creates a string with either fish or pumpkins hanging on the string
(define (decorations k) >decorations is the recursive function which hangs all the decorations together
(if (= k 1)
(decoration r 10) > here decoration is to be replaced with either a pumpkin or a fish as stated in the parameters
(ht-append (decoration r 10) > ht-append is a function that appends 2 figures Horizontally at the Top
(decorations (- k 1)))))
(hang-by-thread (decorations n))) > hang by thread is a function that hangs all the decorations at a string
所有的名字都应该是不言自明的,这个函数需要一个装饰物,一条鱼或一个南瓜,然后用一根线把它挂起来。但是鱼有 3 个参数,南瓜有 2 个,这导致了错误。所以在之前的练习中,我们必须做一个额外的定义,叫做 fish-square,它只使用 2 个参数来制作一条鱼。现在我们必须使用 lambda 来实现同样的平方鱼。任何帮助是极大的赞赏
(define (fish-square wh l) > this is the fish square functio which makes a fish but with 2 times the same parameter so it looks like a square
(vc-append (filled-rectangle 2 l) (fish wh wh))) > the l is the length of the string that attaches the fish to the string at the top
鱼函数只是 (fish xy) x 使它更长, y 使它更高。南瓜函数只是(南瓜 xy)同样的故事
所以我的问题是,如何重写给定的代码,但使用 lambda 作为参数。我会上传一张图片,但我的声誉不够高:s