aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Proctor <simon.proctor@zoopla.co.uk>2021-02-01 14:27:11 +0000
committerSimon Proctor <simon.proctor@zoopla.co.uk>2021-02-01 14:27:11 +0000
commit92d4c70e103ea48c23b30703ce19cce5e018da1b (patch)
tree37278e3e886ebe1570404b1365ac6f71ef7b49c5
parentebe894828aade717f372f58c8de4af65869786cf (diff)
downloadperlweeklychallenge-club-92d4c70e103ea48c23b30703ce19cce5e018da1b.tar.gz
perlweeklychallenge-club-92d4c70e103ea48c23b30703ce19cce5e018da1b.tar.bz2
perlweeklychallenge-club-92d4c70e103ea48c23b30703ce19cce5e018da1b.zip
Updates based on Markus's valid point
-rw-r--r--challenge-098/simon-proctor/raku/ch-1.raku15
1 files changed, 6 insertions, 9 deletions
diff --git a/challenge-098/simon-proctor/raku/ch-1.raku b/challenge-098/simon-proctor/raku/ch-1.raku
index db223dc415..d3aa7b60f6 100644
--- a/challenge-098/simon-proctor/raku/ch-1.raku
+++ b/challenge-098/simon-proctor/raku/ch-1.raku
@@ -21,26 +21,23 @@ say "Self referential code is fun right?";
# While we have a truthy input
while ( my $val = prompt( "How many characters should I print? " ) ) {
- my $rval = $val.Int();
- # If $rval couldn't be cast to an Int it's a Failure which is Boolean false
- # If it was a number then we check it matches the value (to catch floating points).
- if ( $rval && $rval ~~ $val ) {
+ if ( $val ~~ Int ) {
# Allow for negative read back.
- if ( $rval < 0 ) {
+ if ( $val < 0 ) {
# If we would read back to beyond the start just reset it.
- if ( $handle.tell() >= $rval.abs ) {
- $handle.seek($rval, SeekFromCurrent );
+ if ( $handle.tell() >= $val.abs ) {
+ $handle.seek($val, SeekFromCurrent );
} else {
$handle.seek(0, SeekFromBeginning );
}
}
- my $res = $handle.readchars($rval.abs);
+ my $res = $handle.readchars($val.abs);
# I thought about reading back displaying backwards but... not instead it
# pulls the pointer back and rereads
say $res;
# If we got back less code points than we asked for (note not bytes)
# we are done.
- if $res.codes != $rval.abs {
+ if $res.codes != $val.abs {
say "That's all folks";
last;
}