Here's a version in #rakulang using declarative higher order techniques, showing 3 major features of the language: lazy sequences, ad-hoc role mixins and postfix form of control flow statements.
my \n = (1..100).pick;
my %a =
Less => "Too Low" but False,
More => "Too High" but False,
Same => "That's right!";
$*IN.lines.first: { .say and .so with %a{ .Int cmp n } }
Raku is also what you call a C-Style language, so it offers the usual control structures, including switch, while, until ( and even "loop", which unconditionally loops forever; no need to feel vaguely guilty writing "while true" ).
Raku is the language you never knew you wanted.
https://raku.org/
#raku on freenode
Pingback: https://twitter.com/liztormato/status/1379129214239174657
Authored Comments
Here you go =)
my $a;
my $n = int rand 100;
$a = <STDIN> and print qw<Low Right High>[ 1 + ($a <=> $n) ], "\n"
while $a != $n;
Here's a version in #rakulang using declarative higher order techniques, showing 3 major features of the language: lazy sequences, ad-hoc role mixins and postfix form of control flow statements.
my \n = (1..100).pick;
my %a =
Less => "Too Low" but False,
More => "Too High" but False,
Same => "That's right!";
$*IN.lines.first: { .say and .so with %a{ .Int cmp n } }
Raku is also what you call a C-Style language, so it offers the usual control structures, including switch, while, until ( and even "loop", which unconditionally loops forever; no need to feel vaguely guilty writing "while true" ).
Raku is the language you never knew you wanted.
https://raku.org/
#raku on freenode
Pingback: https://twitter.com/liztormato/status/1379129214239174657