Arithmetic evaluation: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: flat before reduction) |
|||
Line 3,557:
=={{header|Perl 6}}==
{{
<lang perl6>sub ev (Str $s --> Num) {
Line 3,575 ⟶ 3,574:
my sub sum ($x) {
[+] flat product($x<product>), map
{ minus($^y[0] eq '-') * product $^y<product> },
|($x[0] or [])
Line 3,581 ⟶ 3,580:
my sub product ($x) {
[*] flat factor($x<factor>), map
{ factor($^y<factor>) ** minus($^y[0] eq '/') },
|($x[0] or [])
|