Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
12
Task/Unix-ls/Forth/unix-ls-1.fth
Normal file
12
Task/Unix-ls/Forth/unix-ls-1.fth
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
256 buffer: filename-buf
|
||||
: each-filename { xt -- } \ xt-consuming variant
|
||||
s" ." open-dir throw { d }
|
||||
begin filename-buf 256 d read-dir throw while
|
||||
filename-buf swap xt execute
|
||||
repeat d close-dir throw ;
|
||||
|
||||
\ immediate variant
|
||||
: each-filename[ s" ." postpone sliteral ]] open-dir throw >r begin filename-buf 256 r@ read-dir throw while filename-buf swap [[ ; immediate compile-only
|
||||
: ]each-filename ]] repeat drop r> close-dir throw [[ ; immediate compile-only
|
||||
|
||||
: ls ( -- ) [: cr type ;] each-filename ;
|
||||
15
Task/Unix-ls/Forth/unix-ls-2.fth
Normal file
15
Task/Unix-ls/Forth/unix-ls-2.fth
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
: save-string ( c-addr u -- a )
|
||||
dup 1+ allocate throw dup >r place r> ;
|
||||
|
||||
require ffl/car.fs
|
||||
: sorted-filenames ( -- car )
|
||||
0 car-new { a }
|
||||
[: swap count rot count compare ;] a car-compare!
|
||||
each-filename[ save-string a car-insert-sorted ]each-filename
|
||||
a ;
|
||||
|
||||
: each-sorted-filename ( xt -- )
|
||||
sorted-filenames { a } a car-execute [: free throw ;] a car-execute a car-free ;
|
||||
|
||||
: ls ( -- )
|
||||
[: count cr type ;] each-sorted-filename ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue