perl实现链表
摘要:perl数组的push,pop,shift,unshift操作可以实现栈,队列及双端队列,但是却不能支持链表的操作,所以创建链表要另寻他法。创建链表sub test { # Create list my $list = undef; foreach (reverse 1..5) { $list = [$list, $_ * $_] ; } }上面的代码创建一个简单的单向链表,它的过程如下[undef, 25][[undef, 25], 16][[[undef, 25], 16], 9][[[[undef, 25], 16], 9], 4][[[...
阅读全文
posted @ 2011-10-19 09:54