具有广义构造函数的二叉树算法
Binary Tree Arithmetic with Generalized Constructors
摘要:
我们描述了算术计算方面的一些著名的自由代数(S1 S,S2 S和有序有根二叉树)的操作,同时强调共同的结构,在所有这些被视为同构的自然数集。构造器和解构器看到通过初始代数语义被推广到递归定义的函数遵守类似的法律。实现使用Scala的应用和unapply一起讨论了一个现实的任意大小的算术包写在Scala的应用程序,基于自由代数的根有序二叉树,它也支持有理数运算通过扩展到有符号有理数的卡尔金-威尔夫双射。
英文摘要:
We describe arithmetic computations in terms of operations on some well known free algebras (S1S, S2S and ordered rooted binary trees) while emphasizing the common structure present in all them when seen as isomorphic with the set of natural numbers. Constructors and deconstructors seen through an initial algebra semantics are generalized to recursively defined functions obeying similar laws. Implementation using Scala's apply and unapply are discussed together with an application to a realistic arbitrary size arithmetic package written in Scala, based on the free algebra of rooted ordered binary trees, which also supports rational number operations through an extension to signed rationals of the Calkin-Wilf bijection.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。