-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.txt
More file actions
44 lines (32 loc) · 760 Bytes
/
string.txt
File metadata and controls
44 lines (32 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
vocabulary string
string definitions decimal
: $variable ( n -- ccc )
<builds dup c, 0 c, here swap dup allot blanks does> 1+ ;
: $maxlen ( $ -- n )
1- c@ ;
: $len ( $ -- n )
c@ ;
: $. ( $ -- )
count type ;
: $empty ( $ -- )
0 swap c! ;
: $empty? ( $ -- f )
$len 0 = ;
: $end ( $ -- a )
dup c@ swap 1+ + ;
: #$! ( a n $ -- )
over over ( a n $ n $ -- )
$maxlen
> 0 ?error
swap >a dup a@ swap c! 1+ a> cmove ;
: $! ( $from $to -- )
>a dup $len swap 1+ swap a> #$! ;
( over over $maxlen swap $len < 0 ?error over $len 1+ cmove ; )
: #$+! ( a n $ -- )
dup >a over over
$len + dup >a
over $maxlen > 0 ?error
$end swap cmove a> a> c! ;
5 $variable five
10 $variable ten
forth definitions