git.alexw.nyc home about git garden
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
f<< /comp/tok.fs

: HASH ( a u -- ) 0 rot> rfor i c@ + 17 * 256 mod next ;

: _?tok< ( -- tok-or-0 )
  in< dup EOF = if drop 0 exit then \ EOF
  newtok
  begin dup ',' <> over ws? not and? while tokacc in< repeat drop curtok ;

: steptok$ tok$ ['] _?tok< ['] (?tok<) realias ; 
: _ 0 begin ?tok< ?dup while c@+ HASH + repeat ;
: solve file$ steptok$ ['] _ f" /aoc/input" file :exec< ;
solve . nl>