Suffix tree: Difference between revisions

(→‎{{header|Perl 6}}: mention of inefficiency)
Line 87:
}
}
}</lang>
}
 
Displaying the tree is done with the code from [[visualize a tree]]:
sub edges($tree) {
gather for $tree[] {
.take for .key, edges .value;
}
}
 
say sort edges suffix-tree 'banana$';</lang>
 
Output matches the one in the task description.
 
'''Extra credit''':
<lang Perl 6>my $tree = root => suffix-tree 'banana$';
.say for visualize-tree $tree, *.key, *.value.list;</lang>
1,934

edits