I have a deep recursive process that outputs a list when it finds a solution to the problem, but this list is created very deep recursively. This is the code:
(define (dfs start target)
(define (dfs-helper start target path new-links final-path)
(display final-path) (newline)
(if (null? final-path)
(if (or (null? new-links) (member start path)) ()
(first-not-null (lambda (x)
(if (= start target) (dfs-helper x target path () (append path (list start))) (dfs-helper x target (append path (list start)) (get-neighbors x) final-path)))
(get-neighbors start))
)
final-path
)
)
(dfs-helper start target () (get-neighbors start) ())
)
(一) 杂质配制。
无论如何,这些产出如下:
...
()
()
(1 7 20 15 22 23 39 40 49 41 31 25 17 18 9 19 26 36 27 12 11 10 3 13 14 21 28 37 43 53 44 52 51 42 50 54 57 58 61 62 60 63)
7
从我所需要的最后一行来看,这是第二点。 正如你可以看到的那样,当我展示最后机会时,我会得到我所希望的东西,但出于某种原因(我想,由于所有休养的电话),最后的实际变量只是7个,而不是我所希望的所有数字的清单。 我怎么能把我的守则带给从最后一行第二行的产出,以便我能够操纵清单。