From 00c29ca217ce17e0ce71b3116784a7180256626c Mon Sep 17 00:00:00 2001 From: Nihilazo Date: Wed, 1 Dec 2021 19:52:13 +0000 Subject: [PATCH] further cleanup --- day1.retro | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/day1.retro b/day1.retro index 8dc4293..96c5618 100644 --- a/day1.retro +++ b/day1.retro @@ -17,9 +17,9 @@ then loop through the file counting up. Retro has a nice word, for-each-line, th ~~~ 'input1 [ s:to-number dup -@prev gt? [ &count v:inc ] if -!prev -&lines v:inc ] file:for-each-line + @prev gt? [ &count v:inc ] if + !prev + &lines v:inc ] file:for-each-line @count n:put ASCII:LF c:put ~~~ @@ -41,11 +41,12 @@ I'm not happy with this solution, but it works. Retro users, help me get better! 'seek-to var @lines #2 - [ -@f file:read-line dup s:length #1 + &seek-to v:inc-by s:to-number -#02 [ @f file:read-line s:to-number ] times -+ + -dup @prev gt? [ &count v:inc ] if !prev -@seek-to @f file:seek ] times + @f file:read-line dup s:length #1 + &seek-to v:inc-by s:to-number + #02 [ @f file:read-line s:to-number ] times + + + + dup @prev gt? [ &count v:inc ] if + !prev + @seek-to @f file:seek ] times @count n:put ASCII:LF c:put @f file:close