Jump to content

Arithmetic evaluation: Difference between revisions

→‎{{header|Perl 6}}: Combine into a single file for ease of testing, fix return type
(Added Kotlin)
(→‎{{header|Perl 6}}: Combine into a single file for ease of testing, fix return type)
Line 3,809:
 
=={{header|Perl 6}}==
{{Works with|rakudo|20152018.1203}}
 
<lang perl6>sub ev (Str $s --> NumNumeric) {
 
grammar expr {
Line 3,847:
sum $/<sum>;
 
}
}</lang>
 
# Testing:
 
<lang perl6>say ev '5'; # 5
say ev '1 + 2 - 3 * 4 / 5'; # 0.6
say ev '1 + 5*3.4 - .5 -4 / -2 * (3+4) -6'; # 25.5
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.