07.fs (1074B) - raw
1 include ../utils/dmath.f 2 36 constant dollar 3 11822 constant dotdot 4 5 variable total 6 \ double stack - 2 cells (4 bytes) 7 : stack create ( n ) here cell+ , 4 * allot does> ( [a] -- ) ; 8 16 stack filesystem 9 10 : push ( n a -- ) tuck @ 2! 4 swap +! ; 11 : pop ( a -- n ) dup -4 swap +! @ 2@ ; 12 : ?empty ( a -- f ) dup @ 4 - = ; 13 : clear-stack ( a -- ) dup 4 + swap ! ; 14 15 : 2!0 0 0 rot 2! ; 16 17 variable tmp 18 : to-double ( a u -- d ) tmp 2!0 19 0 do dup r@ + c@ h# 30 - 0 20 tmp 2@ 10 1 m*/ d+ tmp 2! loop drop tmp 2@ ; 21 22 \ stack / a 23 \ small- 24 \ / = 13737513 + 850456 25 \ a = 29 26 \ e = 584 27 \ cd .. -> check if your value is < 100k, if so, add to total 28 29 10000 constant deadbuf 30 : clear-line deadbuf 32 accept drop ; 31 : read-line ( -- a u ) pad pad 40 accept ; 32 : cd 2 accept clear-line dotdot = if then \ read the cd parameter, if it is dotdot, do the above logic ; 33 : ls \ read until dollar sign, get value, push to stack 34 begin 35 dollar <> while 36 37 repeat 38 drop 39 pad 40 accept 40 pad 40 accept 41 ; 42 : $ noop ; 43 : dir pad 40 accept drop ; \ eats input. ignore this line 44 45 include sample.txt 46 47 \ current directorgt