数据结构 – 如何创建像树一样的数据结构
发布时间:2020-12-16 06:19:54 所属栏目:大数据 来源:网络整理
导读:对于我的项目,我需要构建一个树结构.我正在寻找一种在树叶上种植它的方法.我通过使用listy结构简化了失败的尝试: my $root = a = (b = (c= Nil));my $here := $root;while $here.value ~~ Pair { $here := $here.value;}$here = d = Nil; 这不起作用,因为我
对于我的项目,我需要构建一个树结构.我正在寻找一种在树叶上种植它的方法.我通过使用listy结构简化了失败的尝试:
my $root = a => (b => (c=> Nil)); my $here := $root; while $here.value ~~ Pair { $here := $here.value; } $here = d => Nil; 这不起作用,因为我当然不能改变Nil. 谢谢, 解决方法
我认为你得到的错误信息“无法分配给不可变值”是因为该值不是
container.这是一个我将叶节点作为容器的示例:
my $root = a => (b => (my $= (c => Nil))); my $here := $root; while $here.value ~~ Pair { $here := $here.value; } $here = d => Nil; 现在,没有错误消息. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |