minor cleanups all over the place

cvs
Slava Pestov 2005-12-10 06:02:13 +00:00
parent 1990a8d859
commit 3174f87b67
32 changed files with 106 additions and 131 deletions

View File

@ -1,5 +1,15 @@
+ 0.80: + 0.80:
- -with combinators are ackward
- cleanups:
alien/compiler
inference/shuffle
inference-words inline-block
io/buffer - use aliens not integers
alien/malloc - use aliens not integers
ui/line-editor - don't use variables
- fix powerpc backend
- <array> ( length initial ) - <array> ( length initial )
- <string> ( length initial ) - <string> ( length initial )
- remove repetitions - remove repetitions
@ -25,7 +35,6 @@ word help sections:
parsing word sections: parsing word sections:
- syntax - syntax
- malloc, free, realloc, memcpy: aliens
- check 'see' - check 'see'
- intrinsic char-slot set-char-slot for x86 - intrinsic char-slot set-char-slot for x86
- closing ui does not stop timers - closing ui does not stop timers

View File

@ -3,6 +3,9 @@
IN: httpd IN: httpd
USING: io hashtables kernel lists namespaces ; USING: io hashtables kernel lists namespaces ;
: file-extension ( filename -- extension )
"." split dup length 1 <= [ drop f ] [ peek ] if ;
: mime-type ( filename -- mime-type ) : mime-type ( filename -- mime-type )
file-extension "mime-types" get file-extension "mime-types" get
hash [ "text/plain" ] unless* ; hash [ "text/plain" ] unless* ;

View File

@ -36,6 +36,10 @@ USING: errors kernel sequences math sequences-internals namespaces arrays ;
#! Complex inner product. #! Complex inner product.
0 [ ** + ] 2reduce ; 0 [ ** + ] 2reduce ;
: proj ( u v -- w )
#! Orthogonal projection of u onto v.
[ [ v. ] keep norm-sq v/n ] keep n*v ;
: minmax ( seq -- min max ) : minmax ( seq -- min max )
#! find the min and max of a seq in one pass #! find the min and max of a seq in one pass
inf -inf rot [ dup pick max -rot nip pick min -rot nip ] each ; inf -inf rot [ dup pick max -rot nip pick min -rot nip ] each ;

View File

@ -15,8 +15,7 @@ M: alien = ( obj obj -- ? )
2drop f 2drop f
] if ; ] if ;
: library ( name -- object ) : library ( name -- object ) "libraries" get hash ;
dup [ "libraries" get hash ] when ;
: load-library ( name -- dll ) : load-library ( name -- dll )
#! Higher level wrapper around dlopen primitive. #! Higher level wrapper around dlopen primitive.

View File

@ -18,24 +18,22 @@ sequences sequences-internals strings words ;
SYMBOL: c-types SYMBOL: c-types
: c-type ( name -- type ) : c-type ( name -- type )
dup c-types get hash [ ] [ dup c-types get hash
"No such C type: " swap append throw f [ ] [ "No such C type: " swap append throw ] ?if ;
] ?if ;
: c-size ( name -- size ) : c-size ( name -- size ) "width" swap c-type hash ;
"width" swap c-type hash ;
: c-getter ( name -- quot ) : c-getter ( name -- quot ) "getter" swap c-type hash ;
"getter" swap c-type hash ;
: c-setter ( name -- quot ) : c-setter ( name -- quot ) "setter" swap c-type hash ;
"setter" swap c-type hash ;
: define-c-type ( quot name -- ) : define-c-type ( quot name -- )
>r <c-type> [ swap bind ] keep r> c-types get set-hash ; >r <c-type> [ swap bind ] keep r> c-types get set-hash ;
inline inline
: <c-object> ( size -- c-ptr ) cell / ceiling <byte-array> ; : bytes>cells cell / ceiling ;
: <c-object> ( size -- c-ptr ) bytes>cells <byte-array> ;
: define-pointer ( type -- ) : define-pointer ( type -- )
"void*" c-type swap "*" append c-types get set-hash ; "void*" c-type swap "*" append c-types get set-hash ;

View File

@ -18,7 +18,7 @@ words ;
"syntax" vocab "syntax" vocab
H{ } clone vocabularies set H{ } clone vocabularies set
f crossref set crossref off
vocabularies get [ "syntax" set [ reveal ] each ] bind vocabularies get [ "syntax" set [ reveal ] each ] bind

View File

@ -12,7 +12,7 @@ USING: kernel math math-internals sequences sequences-internals ;
] all? 2nip ] all? 2nip
] [ ] [
2drop f 2drop f
] if ; flushable ] if ; inline
IN: arrays IN: arrays

View File

@ -15,7 +15,7 @@ UNION: sequence array string sbuf vector ;
dup length [ >r 2dup r> 2nth-unsafe = ] all? 2nip dup length [ >r 2dup r> 2nth-unsafe = ] all? 2nip
] [ ] [
2drop f 2drop f
] if ; flushable ] if ; inline
M: sequence = ( obj seq -- ? ) M: sequence = ( obj seq -- ? )
2dup eq? [ 2dup eq? [

View File

@ -6,10 +6,7 @@ USING: errors generic kernel math math-internals strings vectors ;
! This file is needed very early in bootstrap. ! This file is needed very early in bootstrap.
! Sequences support the following protocol. Concrete examples ! Sequences support the following protocol. Concrete examples
! are strings, string buffers, vectors, and arrays. Arrays are ! are strings, string buffers, vectors, and arrays.
! low level and no | quot: elt -- ? t bounds-checked; they are in the
! kernel-internals vocabulary, so don't use them unless you have
! a good reason.
GENERIC: empty? ( sequence -- ? ) flushable GENERIC: empty? ( sequence -- ? ) flushable
GENERIC: length ( sequence -- n ) flushable GENERIC: length ( sequence -- n ) flushable

View File

@ -11,8 +11,7 @@ sequences strings ;
<repeated> >string ; inline <repeated> >string ; inline
: padding ( string count char -- string ) : padding ( string count char -- string )
>r swap length - dup 0 <= [ r> 2drop "" ] [ r> fill ] if ; >r swap length - 0 max r> fill ; flushable
flushable
: pad-left ( string count char -- string ) : pad-left ( string count char -- string )
pick >r padding r> append ; flushable pick >r padding r> append ; flushable
@ -21,7 +20,7 @@ sequences strings ;
pick >r padding r> swap append ; flushable pick >r padding r> swap append ; flushable
: ch>string ( ch -- str ) : ch>string ( ch -- str )
1 <sbuf> [ push ] keep (sbuf>string) ; flushable 1 swap fill ; flushable
: >sbuf ( seq -- sbuf ) : >sbuf ( seq -- sbuf )
dup length <sbuf> [ swap nappend ] keep ; inline dup length <sbuf> [ swap nappend ] keep ; inline

View File

@ -0,0 +1,15 @@
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: compiler-backend
USING: alien assembler compiler inference kernel
kernel-internals lists math memory namespaces words ;
M: %alien-invoke generate-node drop ;
M: %parameter generate-node drop ;
M: %unbox generate-node drop ;
M: %box generate-node drop ;
M: %cleanup generate-node drop ;

View File

@ -17,6 +17,13 @@ USING: assembler compiler-backend kernel sequences ;
: vregs { RAX RCX RDX RSI RDI R8 R9 R10 R11 } ; inline : vregs { RAX RCX RDX RSI RDI R8 R9 R10 R11 } ; inline
: param-regs { R9 R8 RCX RDX RSI RDI } ;
DEFER: compile-c-call
: compile-c-call* ( symbol dll -- operands )
param-regs swap [ MOV ] 2each compile-c-call ;
! FIXME ! FIXME
M: int-regs fastcall-regs drop 0 ; M: int-regs fastcall-regs drop 0 ;
M: int-regs reg-class-size drop 4 ; M: int-regs reg-class-size drop 4 ;

View File

@ -55,14 +55,8 @@ SYMBOL: previous-offset
M: %label generate-node ( vop -- ) M: %label generate-node ( vop -- )
vop-label save-xt ; vop-label save-xt ;
M: %end-dispatch generate-node ( vop -- ) drop ; M: %target-label generate-node ( vop -- )
drop label 0 assemble-cell absolute-cell ;
: compile-target ( word -- ) 0 assemble-cell absolute-cell ;
M: %target-label generate-node vop-label compile-target ;
M: %target generate-node
vop-label dup postpone-word compile-target ;
M: %parameters generate-node ( vop -- ) drop ; M: %parameters generate-node ( vop -- ) drop ;

View File

@ -77,8 +77,7 @@ M: #if linearize* ( node -- )
in-1 in-1
-1 %inc-d , -1 %inc-d ,
0 %dispatch , 0 %dispatch ,
[ <label> dup %target-label , cons ] map [ <label> dup %target-label , cons ] map ;
%end-dispatch , ;
: dispatch-body ( label/param -- ) : dispatch-body ( label/param -- )
[ uncons %label , linearize* ] each ; [ uncons %label , linearize* ] each ;

View File

@ -147,14 +147,6 @@ TUPLE: %target-label ;
C: %target-label make-vop ; C: %target-label make-vop ;
: %target-label label-vop <%target-label> ; : %target-label label-vop <%target-label> ;
TUPLE: %target ;
C: %target make-vop ;
: %target label-vop <%target> ;
TUPLE: %end-dispatch ;
C: %end-dispatch make-vop ;
: %end-dispatch empty-vop <%end-dispatch> ;
! stack operations ! stack operations
TUPLE: %peek ; TUPLE: %peek ;
C: %peek make-vop ; C: %peek make-vop ;

View File

@ -17,6 +17,12 @@ USING: assembler compiler-backend kernel sequences ;
: vregs { EAX ECX EDX } ; inline : vregs { EAX ECX EDX } ; inline
DEFER: compile-c-call
: compile-c-call* ( symbol dll args -- operands )
[ [ PUSH ] each compile-c-call ] keep
[ drop 0 scratch POP ] each ;
! On x86, parameters are never passed in registers. ! On x86, parameters are never passed in registers.
M: int-regs fastcall-regs drop 0 ; M: int-regs fastcall-regs drop 0 ;
M: int-regs reg-class-size drop 4 ; M: int-regs reg-class-size drop 4 ;

View File

@ -1,8 +1,8 @@
! Copyright (C) 2005 Slava Pestov. ! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license. ! See http://factor.sf.net/license.txt for BSD license.
IN: compiler-backend IN: compiler-backend
USING: assembler compiler errors kernel kernel-internals math USING: arrays assembler compiler errors kernel kernel-internals
math-internals memory namespaces words ; math math-internals memory namespaces words ;
: literal-overflow ( -- dest src ) : literal-overflow ( -- dest src )
#! Called if the src operand is a literal. #! Called if the src operand is a literal.
@ -25,11 +25,9 @@ math-internals memory namespaces words ;
! Compute a result, this time it will fit. ! Compute a result, this time it will fit.
r> execute r> execute
! Create a bignum. ! Create a bignum.
0 output-operand PUSH "s48_long_to_bignum" f 0 output-operand 1array compile-c-call*
"s48_long_to_bignum" f compile-c-call
! An untagged pointer to the bignum is now in EAX; tag it ! An untagged pointer to the bignum is now in EAX; tag it
return-reg bignum-tag OR return-reg bignum-tag OR
0 scratch POP
"end" get save-xt ; inline "end" get save-xt ; inline
M: %fixnum+ generate-node ( vop -- ) M: %fixnum+ generate-node ( vop -- )
@ -46,20 +44,14 @@ M: %fixnum* generate-node ( vop -- )
0 input-operand IMUL 0 input-operand IMUL
<label> "end" set <label> "end" set
"end" get JNO "end" get JNO
remainder-reg PUSH "s48_long_long_to_bignum" f
1 input-operand PUSH remainder-reg 1 input-operand 2array compile-c-call*
"s48_long_long_to_bignum" f compile-c-call
0 scratch POP
0 scratch POP
! now we have to shift it by three bits to remove the second ! now we have to shift it by three bits to remove the second
! tag ! tag
tag-bits neg PUSH "s48_bignum_arithmetic_shift" f
1 input-operand PUSH tag-bits neg 1 input-operand 2array compile-c-call*
"s48_bignum_arithmetic_shift" f compile-c-call
! an untagged pointer to the bignum is now in EAX; tag it ! an untagged pointer to the bignum is now in EAX; tag it
return-reg bignum-tag OR return-reg bignum-tag OR
0 scratch POP
0 scratch POP
"end" get save-xt ; "end" get save-xt ;
M: %fixnum-mod generate-node ( vop -- ) M: %fixnum-mod generate-node ( vop -- )
@ -85,12 +77,10 @@ M: %fixnum-mod generate-node ( vop -- )
"end" get JNO "end" get JNO
! There was an overflow, so make ECX into a bignum. we must ! There was an overflow, so make ECX into a bignum. we must
! save EDX since its volatile. ! save EDX since its volatile.
remainder-reg PUSH "s48_long_to_bignum" f
0 input-operand PUSH remainder-reg 0 input-operand 2array compile-c-call*
"s48_long_to_bignum" f compile-c-call
! An untagged pointer to the bignum is now in EAX; tag it ! An untagged pointer to the bignum is now in EAX; tag it
return-reg bignum-tag OR return-reg bignum-tag OR
0 input-operand POP
! the remainder is now in EDX ! the remainder is now in EDX
remainder-reg POP remainder-reg POP
"end" get save-xt ; "end" get save-xt ;
@ -126,16 +116,12 @@ M: %fixnum<< generate-node
"no-overflow" get JBE "no-overflow" get JBE
! there is going to be an overflow, make a bignum ! there is going to be an overflow, make a bignum
1 input-operand tag-bits SAR 1 input-operand tag-bits SAR
0 input PUSH "s48_long_to_bignum" f
1 input-operand PUSH 0 input 1 input-operand 2array compile-c-call*
"s48_long_to_bignum" f compile-c-call "s48_bignum_arithmetic_shift" f
0 scratch POP 1 input-operand 1array compile-c-call*
1 input-operand PUSH
"s48_bignum_arithmetic_shift" f compile-c-call
! tag the result ! tag the result
1 input-operand bignum-tag OR 1 input-operand bignum-tag OR
0 scratch POP
1 scratch POP
"end" get JMP "end" get JMP
! there is not going to be an overflow ! there is not going to be an overflow
"no-overflow" get save-xt "no-overflow" get save-xt

View File

@ -7,21 +7,21 @@ kernel-internals lists math memory namespaces sequences words ;
! Not used on x86 ! Not used on x86
M: %prologue generate-node drop ; M: %prologue generate-node drop ;
: compile-dlsym ( symbol dll quot -- ) : compile-c-call ( symbol dll -- )
>r 2dup dlsym r> call 1 0 rel-dlsym ; inline 2dup dlsym CALL 1 0 rel-dlsym ;
: compile-c-call ( symbol dll -- ) [ CALL ] compile-dlsym ; : (call-label)
label dup postpone-word
dup primitive? [ address-operand ] when ;
M: %call generate-node ( vop -- ) M: %call generate-node ( vop -- )
drop label dup postpone-word drop (call-label) CALL ;
dup primitive? [ address-operand ] when CALL ;
M: %call-label generate-node ( vop -- ) M: %call-label generate-node ( vop -- )
drop label CALL ; drop label CALL ;
M: %jump generate-node ( vop -- ) M: %jump generate-node ( vop -- )
drop label dup postpone-word drop (call-label) JMP ;
dup primitive? [ address-operand ] when JMP ;
M: %jump-label generate-node ( vop -- ) M: %jump-label generate-node ( vop -- )
drop label JMP ; drop label JMP ;

View File

@ -46,10 +46,12 @@ M: %fast-set-slot generate-node ( vop -- )
M: %getenv generate-node ( vop -- ) M: %getenv generate-node ( vop -- )
drop drop
0 output-operand 0 input userenv@ 1array MOV 0 output-operand 0 input userenv@ MOV
0 input 0 rel-userenv ; 0 input 0 rel-userenv
0 output-operand dup 1array MOV ;
M: %setenv generate-node ( vop -- ) M: %setenv generate-node ( vop -- )
drop drop
1 input userenv@ 1array 0 input-operand MOV 0 scratch 1 input userenv@ MOV
1 input 0 rel-userenv ; 1 input 0 rel-userenv
0 scratch 1array 0 input-operand MOV ;

View File

@ -29,11 +29,8 @@ parser sequences strings words ;
: define-slot ( class slot reader writer -- ) : define-slot ( class slot reader writer -- )
>r >r 2dup r> define-reader r> define-writer ; >r >r 2dup r> define-reader r> define-writer ;
: ?create ( { name vocab } -- word )
dup [ first2 create ] when ;
: intern-slots ( spec -- spec ) : intern-slots ( spec -- spec )
[ first3 [ ?create ] 2apply 3array ] map ; [ first3 [ dup [ first2 create ] when ] 2apply 3array ] map ;
: define-slots ( class spec -- ) : define-slots ( class spec -- )
#! Define a collection of slot readers and writers for the #! Define a collection of slot readers and writers for the

View File

@ -9,9 +9,6 @@ namespaces parser prettyprint sequences strings vectors words ;
#! shorter, pad it with unknown results at the bottom. #! shorter, pad it with unknown results at the bottom.
dup 0 [ length max ] reduce swap [ add-inputs ] map-with ; dup 0 [ length max ] reduce swap [ add-inputs ] map-with ;
: unify-length ( seq seq -- seq )
2array unify-lengths first2 ;
: unify-values ( seq -- value ) : unify-values ( seq -- value )
#! If all values in list are equal, return the value. #! If all values in list are equal, return the value.
#! Otherwise, unify. #! Otherwise, unify.

View File

@ -118,14 +118,6 @@ SYMBOL: @
{ { @ 1 } [ 2drop 0 ] } { { @ 1 } [ 2drop 0 ] }
} define-identities } define-identities
! [ ^ ] {
! { { 1 @ } [ 2drop 1 ] }
! { { @ 1 } [ drop ] }
! { { @ 2 } [ drop dup * ] }
! { { @ -1 } [ drop 1 swap / ] }
! { { @ -2 } [ drop dup * 1 swap / ] }
! } define-identities
[ bitand fixnum-bitand bignum-bitand ] { [ bitand fixnum-bitand bignum-bitand ] {
{ { @ -1 } [ drop ] } { { @ -1 } [ drop ] }
{ { -1 @ } [ nip ] } { { -1 @ } [ nip ] }

View File

@ -1,5 +1,5 @@
IN: optimizer IN: optimizer
USING: inference kernel lists sequences words ; USING: arrays inference kernel lists sequences words ;
! #if --> X ! #if --> X
! | ! |
@ -24,8 +24,10 @@ M: node split-node* ( node -- ) drop ;
: post-inline ( #return/#values #call/#merge -- ) : post-inline ( #return/#values #call/#merge -- )
dup [ dup [
[ >r node-in-d r> node-out-d unify-length ] keep [
node-successor subst-values >r node-in-d r> node-out-d
2array unify-lengths first2
] keep node-successor subst-values
] [ ] [
2drop 2drop
] if ; ] if ;

View File

@ -17,9 +17,6 @@ styles ;
: file-length ( file -- length ) stat third ; : file-length ( file -- length ) stat third ;
: file-extension ( filename -- extension )
"." split dup length 1 <= [ drop f ] [ peek ] if ;
: resource-path ( path -- path ) : resource-path ( path -- path )
"resource-path" get [ "." ] unless* swap path+ ; "resource-path" get [ "." ] unless* swap path+ ;

View File

@ -15,10 +15,10 @@ USING: kernel math math-internals ;
: acosech recip asinh ; inline : acosech recip asinh ; inline
: atanh dup 1+ swap 1- neg / log 2 / ; inline : atanh dup 1+ swap 1- neg / log 2 / ; inline
: acoth recip atanh ; inline : acoth recip atanh ; inline
: <=1 ( x -- ? ) dup complex? [ drop f ] [ abs 1 <= ] if ; inline : [-1,1]? ( x -- ? ) dup complex? [ drop f ] [ abs 1 <= ] if ; inline
: asin dup <=1 [ fasin ] [ i * asinh -i * ] if ; inline : asin dup [-1,1]? [ fasin ] [ i * asinh -i * ] if ; inline
: acos dup <=1 [ facos ] [ asin pi 2 / swap - ] if ; inline : acos dup [-1,1]? [ facos ] [ asin pi 2 / swap - ] if ; inline
: atan dup <=1 [ fatan ] [ i * atanh i * ] if ; inline : atan dup [-1,1]? [ fatan ] [ i * atanh i * ] if ; inline
: asec recip acos ; inline : asec recip acos ; inline
: acosec recip asin ; inline : acosec recip asin ; inline
: acot recip atan ; inline : acot recip atan ; inline

View File

@ -8,3 +8,4 @@ IN: math
: -inf -1.0 0.0 / ; inline : -inf -1.0 0.0 / ; inline
: e 2.7182818284590452354 ; inline : e 2.7182818284590452354 ; inline
: pi 3.14159265358979323846 ; inline : pi 3.14159265358979323846 ; inline
: epsilon 2.2204460492503131e-16 ; inline

View File

@ -24,5 +24,3 @@ M: float /f float/f ;
M: float 1+ 1.0 float+ ; M: float 1+ 1.0 float+ ;
M: float 1- 1.0 float- ; M: float 1- 1.0 float- ;
: epsilon 2.2204460492503131e-16 ; inline

View File

@ -37,7 +37,3 @@ USING: arrays generic kernel sequences ;
: normalize ( vec -- uvec ) : normalize ( vec -- uvec )
#! Unit vector with same direction as vec. #! Unit vector with same direction as vec.
dup norm v/n ; dup norm v/n ;
: proj ( u v -- w )
#! Orthogonal projection of u onto v.
[ [ v. ] keep norm-sq v/n ] keep n*v ;

View File

@ -1,8 +0,0 @@
IN: temporary
USE: io
USE: lists
USE: test
[ "txt" ] [ "foo.txt" file-extension ] unit-test
[ f ] [ "foobar" file-extension ] unit-test
[ "txt" ] [ "foo.bar.txt" file-extension ] unit-test

View File

@ -81,11 +81,9 @@ SYMBOL: failures
"collections/hashtables" "collections/sbuf" "collections/hashtables" "collections/sbuf"
"collections/strings" "collections/namespaces" "collections/strings" "collections/namespaces"
"collections/vectors" "collections/sequences" "collections/vectors" "collections/sequences"
"collections/queues" "collections/queues" "generic" "tuple" "parser"
"generic" "tuple" "files" "parser"
"parse-number" "init" "io/io" "parse-number" "init" "io/io"
"words" "prettyprint" "random" "words" "prettyprint" "random" "stream" "math/bitops"
"stream" "math/bitops"
"math/math-combinators" "math/rational" "math/float" "math/math-combinators" "math/rational" "math/float"
"math/complex" "math/irrational" "math/complex" "math/irrational"
"math/integer" "threads" "parsing-word" "math/integer" "threads" "parsing-word"

View File

@ -13,11 +13,6 @@ USING: namespaces ;
: byte-bit ( n alien -- byte bit ) : byte-bit ( n alien -- byte bit )
over -5 shift alien-unsigned-4 swap 31 bitand ; over -5 shift alien-unsigned-4 swap 31 bitand ;
: bit-length ( n -- n ) cell / ceiling ;
: <bit-array> ( n -- array )
bit-length <byte-array> ;
: bit-nth ( n alien -- ? ) : bit-nth ( n alien -- ? )
byte-bit 1 swap shift bitand 0 > ; byte-bit 1 swap shift bitand 0 > ;
@ -29,7 +24,7 @@ USING: namespaces ;
swap -5 shift set-alien-unsigned-4 ; swap -5 shift set-alien-unsigned-4 ;
: clear-bits ( alien len -- ) : clear-bits ( alien len -- )
bit-length [ 0 -rot set-alien-unsigned-cell ] each-with ; bytes>cells [ 0 -rot set-alien-unsigned-cell ] each-with ;
! Global variables ! Global variables
SYMBOL: read-fdset SYMBOL: read-fdset
@ -322,8 +317,8 @@ USE: io
#! other time can have unintended consequences. #! other time can have unintended consequences.
global [ global [
H{ } clone read-tasks set H{ } clone read-tasks set
FD_SETSIZE <bit-array> read-fdset set FD_SETSIZE <c-object> read-fdset set
H{ } clone write-tasks set H{ } clone write-tasks set
FD_SETSIZE <bit-array> write-fdset set FD_SETSIZE <c-object> write-fdset set
0 1 t <fd-stream> stdio set 0 1 t <fd-stream> stdio set
] bind ; ] bind ;

View File

@ -47,7 +47,7 @@ SYMBOL: vocabularies
: lookup ( name vocab -- word ) vocab ?hash ; : lookup ( name vocab -- word ) vocab ?hash ;
: search ( name vocabs -- word ) : search ( name vocabs -- word )
[ lookup ] map-with [ ] find nip ; dupd [ lookup ] find nip ?hash ;
: reveal ( word -- ) : reveal ( word -- )
#! Add a new word to its vocabulary. #! Add a new word to its vocabulary.