aoc-forth

Advent of code solutions in UF forth
git clone git://git.alexwennerberg.com/aoc-forth
Log | Files | Refs | README

misc.f (436B) - raw


      1 \ Some utility words that may be useful. 
      2 \ probably will copy/pasta each day rather than using include
      3 
      4 \ literals
      5 : crl #0d ;
      6 
      7 : ascii ( | <c> -- c ) bl word 1+ c@ state @ if literal then ; immediate
      8 
      9 \ convert numeric string to num
     10 \ wonky but it works
     11 : to-num ( a u -- n ) 0 -rot 0 do dup r@ + c@ h# 30 - rot 10 * + swap loop drop ;
     12 
     13 \ Not very general-purpose -- only reads 16 chars
     14 : read-num ( -- n ) pad pad 16 accept to-num ;