什么是相互递归类型? [英] what is a mutually recursive type?

查看:185
本文介绍了什么是相互递归类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在ML中,则递归数据类型的示例为:

If in ML, an example of a recursive datatype is:

datatype llist = Nil | Node of int * llist

在ML中,什么是相互递归的数据类型?它的一个例子是什么?

What is a mutually recursive datatype and whats an example of it, in ML?

推荐答案

一个这样的例子就是这些愚蠢的数据类型.

One such example could be these stupid datatypes.

datatype a = A | Ab of b
and      b = B | Ba of a

它们没有任何意义,但是它们表明可以使用and关键字(与函数相同)来引用通常无法实现的预先"内容

They make no sense, but they show that it is possible to use the and keyword (just as with functions) to reference something "ahead" which is normally not possible

它们是相互(因为它们都...)递归(...彼此引用)

这篇关于什么是相互递归类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆