算术简化器的阅读嵌入与binding导入[#38]

算术简化器来自(flora expression-language)。transclude展示其代码tree,interpret与simplify的调用则依赖use-modules;两种复用的来源相同,作用不同。

算术简化器 simplify 的递归定义[lp-simplify]

(define (simplify expression)
   (match expression
     ((? integer? n) n)
     ((? symbol? name) name)
     ((operation left right)
      (if (memq operation '(+ *))
          (rewrite operation (simplify left) (simplify right))
          (throw 'invalid-expression expression)))
     (_ (throw 'invalid-expression expression))))

use-modules建立程序依赖;link与transclude建立阅读关系。后者不会偷偷改变当前环境,前者也不自动决定文章在哪里展示代码。这个区别让阅读顺序可以不同于程序依赖顺序。