3125a52331/forthlets/hangman/dict.retro
| fc349e2cf15e1e11664eb67f38cf4acd59fe042c | 3125a52331ae6d7a6bb77d0ce92a95ddc2580547 | ||
|---|---|---|---|
7 | ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) | 7 | ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) |
8 | 8 | ||
9 | include library/data/random-mwc.retro | 9 | include library/data/random-mwc.retro |
10 | include library/files.retro | ||
10 | 11 | ||
11 | ( --[ Variables ]--------------------------------------------- ) | 12 | ( --[ Variables ]--------------------------------------------- ) |
12 | 13 | ||
... | ... | ||
28 | : rand-off ( -n ) dict-size @ >random ; | 29 | : rand-off ( -n ) dict-size @ >random ; |
29 | : rand-pos ( -n ) rand-off dict @ fseek drop ; | 30 | : rand-pos ( -n ) rand-off dict @ fseek drop ; |
30 | 31 | ||
31 | : >line ( - ) repeat dict @ here fread drop | 32 | : >line ( - ) repeat dict @ fread 10 =if ;then again ; |
32 | here @ 10 =if ;then again ; | ||
33 | 33 | ||
34 | : readline ( - ) dict-word repeat dict @ over fread drop | 34 | : readline ( - ) dict-word repeat dict @ over fread! drop |
35 | dup @ 10 =if 0 swap ! ;; else 1+ then again ; | 35 | dup @ 10 =if 0 swap ! ;; else 1+ then again ; |
36 | 36 | ||
37 | : rand-word ( - ) rand-pos >line readline ; | 37 | : rand-word ( - ) rand-pos >line readline ; |
Download diff