toolkit.txt


\ toolkit 99.2.12 7:24 pm NAB
needs core-ext
decimal

\ Place a1 n1 as counted string at a2:
: place ( a1 n1 a2 -- )
  2dup 2>r  char+ swap  move  2r> c! ;

: place, ( a1 n1 -- )
  here  over 1+ chars allot  place ;

\ Compute loop bounds for a string:
: bounds ( a n -- a+n a )
  chars over + swap ;

: >lower ( C -- c )
  dup [char] A [char] Z 1+ within
  if  32 or  then ;
: >upper ( c -- C )
  dup [char] a [char] z 1+ within
  if  223 and  then ;

\ Append string s to the end of t:
: append ( at ut as us -- at ut+us )
  dup >r  2over +  swap move  r> + ;

: array ( cells <name> -- )
  create  cells  here over 0 fill  allot
  does> swap cells + ;

: under+ ( n1 x1 n2 -- n1+n2 x1 )
  rot + swap ;

: enum ( n -- )  create ,
  does> ( -- n )
  dup  @ constant  1 swap +! ;

: [end]  begin refill 0= until ;

: [defined]  bl word find nip 0<> ;

: 0allot ( chars -- )
  here over allot  swap 0 fill ;

: 3drop 2drop drop ;
: 4drop 2drop 2drop ;
: 6drop 3drop 3drop ;


  HTMLized by Forth2HTML