planckforth/lib/core.fs

44 lines
752 B
Forth
Raw Normal View History

2021-01-13 11:29:46 +01:00
\ planckforth -
\ Copyright (C) 2021 nineties
2021-01-16 10:52:47 +01:00
\ Ignore test codes. lib/tester.fs will redefine this when
\ running tests.
: T{
begin
word throw
s" }T" streq if exit then
again
;
2021-01-17 15:29:25 +01:00
s" Invalid argument" exception constant INVALID-ARGUMENT
: check-argument ( f -- )
unless INVALID-ARGUMENT throw then
;
2021-12-04 09:22:12 +01:00
defined? roll [unless]
2021-12-04 11:21:55 +01:00
: roll ( w[n-1] ... w0 n -- w0 w[n-2] ... w0 w[n-1] )
2021-12-04 09:22:12 +01:00
dup 0<= if drop else swap >r 1- recurse r> swap then
;
[then]
private{
( === Cons Cell === )
struct
cell% field first
cell% field second
end-struct cons-cell%
: cons ( a b -- cons )
cons-cell% %allocate throw
tuck second !
tuck first !
; export
: car first @ ; export
: cdr second @ ; export
}private