adding some more primitives

This commit is contained in:
Danny Yoo 2011-08-19 15:05:07 -04:00
parent 47d2708f23
commit 9ef4e5ef45
5 changed files with 63 additions and 2 deletions

View File

@ -809,6 +809,36 @@
});
installPrimitiveProcedure(
'boolean?',
1,
function(MACHINE) {
var v = MACHINE.env[MACHINE.env.length - 1];
return (v === true || v === false);
});
installPrimitiveProcedure(
'char?',
1,
function(MACHINE) {
return baselib.chars.isChar(MACHINE.env[MACHINE.env.length -1 ]);
});
installPrimitiveProcedure(
'char=?',
baselib.arity.makeArityAtLeast(2),
function(MACHINE) {
var s = checkChar(MACHINE, 'char=?', 0).val;
var i;
for (i = 1; i < MACHINE.argcount; i++) {
if (checkChar(MACHINE, 'char=?', i).val !== s) {
return false;
}
}
return true;
});

View File

@ -266,8 +266,8 @@ raise-mismatch-error
;; void?
symbol?
string?
;; char?
;; boolean?
char?
boolean?
vector?
;; struct?
;; eof-object?

View File

@ -0,0 +1,13 @@
false
true
false
false
false
false
false
true
false
true
false
false
true

View File

@ -0,0 +1,17 @@
#lang planet dyoo/whalesong
(boolean? "t")
(boolean? #t)
(boolean? 0)
(boolean? #\t)
(char? "t")
(char? #t)
(char? 0)
(char? #\t)
(char=? #\a #\b)
(char=? #\a #\a)
(char=? #\a #\a #\b)
(char=? #\a #\b #\a)
(char=? #\a #\a #\a)

View File

@ -6,6 +6,7 @@
;; content vs. a text file with the same name, but with the .rkt file
;; type replaced with .expected.
(test "more-tests/booleans.rkt")
(test "more-tests/string-tests.rkt")
(test "more-tests/numbers.rkt")
(test "more-tests/hello.rkt")