all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
3
Task/String-length/Forth/string-length-1.fth
Normal file
3
Task/String-length/Forth/string-length-1.fth
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
CREATE s ," Hello world" \ create string "s"
|
||||
s C@ ( -- length=11 )
|
||||
s COUNT ( addr len ) \ convert to a stack string, described below
|
||||
2
Task/String-length/Forth/string-length-2.fth
Normal file
2
Task/String-length/Forth/string-length-2.fth
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
S" string" ( addr len)
|
||||
DUP . \ 6
|
||||
9
Task/String-length/Forth/string-length-3.fth
Normal file
9
Task/String-length/Forth/string-length-3.fth
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
2 base !
|
||||
: utf8+ ( str -- str )
|
||||
begin
|
||||
char+
|
||||
dup c@
|
||||
11000000 and
|
||||
10000000 <>
|
||||
until ;
|
||||
decimal
|
||||
8
Task/String-length/Forth/string-length-4.fth
Normal file
8
Task/String-length/Forth/string-length-4.fth
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
: count-utf8 ( zstr -- n )
|
||||
0
|
||||
begin
|
||||
swap dup c@
|
||||
while
|
||||
utf8+
|
||||
swap 1+
|
||||
repeat drop ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue