清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#!/usr/bin/env perl6 my @nums; grammar InfixNotation { rule TOP { ^ <expr> $ } token expr { <left>+ % <op> } token left { '(' <expr> ')' | <@nums> } token op { < + - * / > } } my $str; while True { @nums = (1 .. 9).roll(4)>>.Str; say "Generate 4 digit : " ~ @nums; print "Now enter your expression:"; $str = ~$*IN.get; if InfixNotation.parse($str) { my $value = $/.EVAL; say "$str = $value"; say $value == 24 ?? "Good job!" !! "Don't lose heart. Come on!"; } else { say "Expression check failed."; } say "Try again Y/N?"; $str = $*IN.get; if $str.lc !~~ "y" { last; } }