使用的自参考名单 [英] Uses of self referencing lists

查看:136
本文介绍了使用的自参考名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道它是可以创建自参考列表语言如Python:

I know it is possible to create a self referencing list in languages like Python:

>>> my_list = [1,2]
>>> my_list.append(my_list)
>>> print my_list
[1,2,[...]]
>>> print my_list[0]
1
>>> print my_list[2]
[1,2,[...]]

从什么自参考名单算法的好处?我不认为一个人的。

What algorithms benefit from self referencing lists? I cannot think of one.

感谢。

推荐答案

自引用列表和,一般说来,圆形的数据结构,可以使得当重新$ P $使用数据结构psenting的曲线图。

Self-referencing lists, and, generally speaking, circular data structures, can be caused when representing a graph using data structures.

例如,考虑的曲线图的此幼稚重新presentation:每个节点是一个原子值,或者说,它连接到的节点的列表。一个圆可能会导致列表以包含包含列表另一个列表。一种自圆,即,从一个节点到它本身的边缘,将导致自引用列表

For example, consider this naive representation of a graph: Each node is either an atomic value, or a list of nodes that it is linked to. A circle may cause a list to contain another list that contains the list. A self-circle, i.e., an edge from a node to itself, will cause a self-referencing list.

这篇关于使用的自参考名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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