Thank You!
ged to a ref.
$part = \(grow($part)) doesn't work either, it creates refs to elements in
the array.
2011/4/29 Uri Guttman
> >>>>> "zs" == z sway writes:
>
> zs> foreach $part (@part) {
> zs> $part =~ s/^\(|\)$//g;
> zs> my @temp = grow($pa
Hi, I've finished it using recursion.
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
#不检查输入算式是否正确
print "输入自然数算式(只允许加法、乘法、括号)\n";
print "输入完成按回车确认,退出请输入0\n\n";
while (1) {
print "Enter the expression : ";
chomp($_ = );
last if not $_;
my @tree = grow($_);
print Dumper(\@tree);
my $result = c
in private (unintentionally, I presume), so I'm CCing the
> list on my reply (I hope it's OK).
>
> On Monday 25 Apr 2011 12:07:54 z sway wrote:
> > Hi,sorry I hadn't said it clearly,what I want to do is to generate a LOL
> > from an expression and try* *not to use a
the expression only contains number and"+*()"
the form of list is like[op,node1,node2...],op is "+"or"*",node can be a
number or a child list.
e.g :1*2+3*4*(5+6)
[ '+', ['*', '1', '2'], ['*', '3', '4', ['+','5', '6'] ] ]
Thanks!