1

The Little Schemer的第 9 章中:

(define align
  (lambda (pora)
    (cond ((atom? pora) pora)
          ((a-pair? (first pora)) (align (shift pora)))
          (else (build (first pora)
                       (align (second pora)))))))

书中大部分函数都有例子,例子一般都有详细的讲解,但没有这个函数。

我不明白如何使用这个功能,所以我无法理解后面的功能。我在网上找不到此功能的示例。

你能给我看一些例子吗?

4

1 回答 1

0

我找到了包含代码和一些示例的存储库:

https://github.com/viswanathgs/The-Little-Schemer/blob/master/ch-09-and-again-and-again-and-again.ss

对齐的例子:

(align '(a b))                     ; (a b)
(align '((a b) c))                 ; (a (b c))
(align '((a b) (c d)))             ; (a (b (c d)))
(align '((a (b c)) (((d e) f) g))) ; (a (b (c (d (e (f g))))))
于 2021-12-25T18:15:40.297 回答