The Lambda Lab
/
projects
/
scheme.forth.jl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Load now returns result of last expression.
[scheme.forth.jl.git]
/
scheme-primitives.4th
diff --git
a/scheme-primitives.4th
b/scheme-primitives.4th
index
03d885b
..
1d2e21c
100644
(file)
--- a/
scheme-primitives.4th
+++ b/
scheme-primitives.4th
@@
-45,7
+45,7
@@
:noname ( args -- boolobj )
2dup 1 ensure-arg-count
:noname ( args -- boolobj )
2dup 1 ensure-arg-count
- car primitive-type istype? -rot 2drop boolean-type
+ car primitive-
proc-
type istype? -rot 2drop boolean-type
; make-primitive procedure?
( = Type conversions = )
; make-primitive procedure?
( = Type conversions = )
@@
-64,34
+64,39
@@
drop character-type
; make-primitive integer->char
drop character-type
; make-primitive integer->char
-: num-to-charlist ( num -- charlist )
- ?dup 0= if
+: fixnum-to-charlist ( fixnum -- charlist )
+ over 0= if
+ 2drop
[char] 0 character-type nil cons
exit
then
[char] 0 character-type nil cons
exit
then
- nil
rot
+ nil
2swap ( charlist fixnum )
begin
begin
-
?dup
0>
+
over
0>
while
while
- dup 10 mod swap 10 / swap
- 2swap rot
- [char] 0 + character-type 2swap
- cons
- rot
+ 2dup swap 10 mod swap ( charlist fixnum fixnummod )
+ 2swap swap 10 / swap ( charlist fixnummod fixnumdiv )
+ -2rot ( fixnumdiv charlist fixnummod )
+
+ drop [char] 0 + character-type 2swap
+ cons ( fixnumdiv newcharlist )
+
+ 2swap
repeat
repeat
+
+ 2drop
;
:noname ( args -- string )
2dup 1 ensure-arg-count
car fixnum-type ensure-arg-type
;
:noname ( args -- string )
2dup 1 ensure-arg-count
car fixnum-type ensure-arg-type
-
dro
p
+
2dup swap abs swa
p
- dup 0< swap abs ( bool num )
- num-to-charlist
- rot if
+ fixnum-to-charlist ( fixnum charlist )
+ 2swap drop 0< if
[char] - character-type 2swap cons
then
[char] - character-type 2swap cons
then
@@
-212,9
+217,12
@@
mod fixnum-type
; make-primitive remainder
mod fixnum-type
; make-primitive remainder
-:noname ( args -- bool )
+variable relcfa
+
+: test-relation ( args -- bool )
2dup nil objeq? if
2dup nil objeq? if
+ 2drop
true boolean-type exit
then
true boolean-type exit
then
@@
-234,8
+242,8
@@
2dup nil objeq? false =
while
2dup car fixnum-type ensure-arg-type ( arg0 args' arg1 )
2dup nil objeq? false =
while
2dup car fixnum-type ensure-arg-type ( arg0 args' arg1 )
- 2rot 2
dup 2rot ( args' arg0 arg0 arg1
)
-
objeq?
false = if
+ 2rot 2
swap 2dup 2rot 2swap ( args' arg1 arg1 arg0
)
+
relcfa @ execute
false = if
2drop 2drop
false boolean-type exit
then
2drop 2drop
false boolean-type exit
then
@@
-245,8
+253,37
@@
2drop 2drop
true boolean-type
2drop 2drop
true boolean-type
+;
+
+: fixnum-lt ( obj1 obj2 -- bool )
+ drop swap drop <
+;
+
+:noname
+ ['] fixnum-lt relcfa !
+ test-relation
+; make-primitive <
+
+: fixnum-gt ( obj1 obj2 -- bool )
+ drop swap drop >
+;
+
+:noname
+ ['] fixnum-gt relcfa !
+ test-relation
+; make-primitive >
+
+: fixnum-eq ( obj1 obj2 -- bool )
+ drop swap drop =
+;
+
+:noname
+ ['] fixnum-eq relcfa !
+ test-relation
; make-primitive =
; make-primitive =
+hide relcfa
+
( = Pairs and Lists = )
:noname ( args -- pair )
( = Pairs and Lists = )
:noname ( args -- pair )