1
A
回答
5
一个这样的例子可能是这些愚蠢的数据类型。
datatype a = A | Ab of b
and b = B | Ba of a
他们就没有任何意义,但它们表明,它可以使用and
关键字(就像使用功能)来引用一些“超前”,这通常是不可能的
它们是相互(因为它们都...)递归(...相互引用)
2
相互递归数据类型的标准基本例子是树和森林:一个森林树木的列表,而一棵树是价值和森林(r的价值oot和子女的子树)。在标准ML这可以被定义为,允许空树:
datatype 'a tree = Empty | Node of 'a * 'a forest
and 'a forest = Nil | Cons of 'a tree * 'a forest
从“Data Types”,在标准ML,由罗伯特·哈珀编程(2000年)。
又如通过产生式规则定义表达式在正式语法,如对于整数的括号的算术表达式如下:
datatype int_exp = plus of int_term * int_term
| minus of int_term * int_term
and int_term = times of int_factor * int_factor
| divide of int_factor * int_factor
| modulo of int_factor * int_factor
and int_factor = int_const of int
| paren of int_exp;
我已在维基百科更新“Mutual recursion”以提供示例(包括标准ML)。
相关问题
- 1. scala中的相互递归类型
- 2. C++相互递归变体类型
- 3. 相互递归数据类型
- 4. 这种相互“递归”叫什么?
- 5. 可能有相互递归类吗?
- 6. 泛型中的“递归类型绑定”是什么意思?
- 7. ANTLR4相互左递归
- 8. 模板互相递归
- 9. 野牛的相互递归
- 10. 相互递归Common Lisp中
- 11. AMD递归互相模块
- 12. ANTLR的相互左递归
- 13. 相互递归问题
- 14. 相互递归的实例?
- 15. ocaml相互递归错误
- 16. 相互左递归ANTLR 4
- 17. 相互递归定义IO
- 18. F#:相互递归函数
- 19. 相互递归let绑定
- 20. 推测一个相互递归的数据类型家族
- 21. 递归和类实例递归的区别是什么
- 22. 什么时候/为什么相互左递归在Antlr中发生?
- 23. 在F#/ Scala中优化相互递归的标准方法是什么?
- 24. 什么是间接递归?
- 25. 什么是递归树?
- 26. 避免在类型类与相互递归默认方法的一个错误
- 27. z3中的相互递归数据类型及其与内置类型的交互
- 28. 递归类型Lensing
- 29. 从左递归规则中去除相互左递归
- 30. 科特林:尾递归的相互递归函数