Add all the A tasks

This commit is contained in:
Ingy döt Net 2013-04-10 14:58:50 -07:00
parent 2dd7375f96
commit 051504d65b
1608 changed files with 18584 additions and 0 deletions

View file

@ -0,0 +1,21 @@
: get ( key len table -- data ) \ 0 if not present
search-wordlist if
>body @
else 0 then ;
: put ( data key len table -- )
>r 2dup r@ search-wordlist if
r> drop nip nip
>body !
else
r> get-current >r set-current \ switch definition word lists
nextname create ,
r> set-current
then ;
wordlist constant bar
5 s" alpha" bar put
9 s" beta" bar put
2 s" gamma" bar put
s" alpha" bar get . \ 5
8 s" Alpha" bar put \ Forth dictionaries are normally case-insensitive
s" alpha" bar get . \ 8

View file

@ -0,0 +1,19 @@
include ffl/hct.fs
\ Create a hash table 'table' in the dictionary with a starting size of 10
10 hct-create htable
\ Insert entries
5 s" foo" htable hct-insert
10 s" bar" htable hct-insert
15 s" baz" htable hct-insert
\ Get entry from the table
s" bar" htable hct-get [IF]
.( Value:) . cr
[ELSE]
.( Entry not present.) cr
[THEN]