我不知道如何让这段代码起作用,这么晚在这里,我认为我的大脑已经停止运作,任何人都在帮我一把吗?球拍 - 从列表中挑选一个随机元素
至今代码:
(define maze-size 15)
(define-struct Cell (x y))
; adjacents : Cell -> list-of-Cells
; Produce a list of the four Cells above, below, left, and right of 'cell'.
(define(adjacents cell x y)
(list
(make-Cell x (+ y 1))
(make-Cell x (- y 1))
(make-Cell (- x 1) y)
(make-Cell (+ x 1) y)))
这里是我得到难倒,我怎么解决这个问题? 注意:下面的代码不起作用。
; random-adjacent : list-of-Cells -> Cell
; Produce a random Cell adjacent to a random Cell from the non-empty list'cells'.
(define (random-adjacent cells)
(random (adjacents cell)))
这是它的行为应该是这样的:
(check-expect (member? (random-adjacent (list (make-Cell 123 104)))
(list (make-Cell 123 105)
(make-Cell 123 103)
(make-Cell 122 104)
(make-Cell 124 104)))
#true)
有没有必要磕碰问题,不工作在SO上。 – uselpa