adding more primitives

This commit is contained in:
Danny Yoo 2011-08-31 15:12:52 -04:00
parent 9a7811f9f1
commit df065ed67f
3 changed files with 103 additions and 9 deletions

View File

@ -854,6 +854,92 @@
installPrimitiveProcedure(
'string-ci=?',
baselib.arity.makeArityAtLeast(1),
function (MACHINE) {
var s = checkString(MACHINE, 'string-ci=?', 0).toString().toUpperCase();
var i;
for (i = 1; i < MACHINE.argcount; i++) {
if (s !== checkString(MACHINE, 'string-ci=?', i).toString().toUpperCase()) {
return false;
}
}
return true;
});
installPrimitiveProcedure(
'string-ci<=?',
baselib.arity.makeArityAtLeast(1),
function (MACHINE) {
var s = checkString(MACHINE, 'string-ci<=?', 0).toString().toUpperCase();
var i;
for (i = 1; i < MACHINE.argcount; i++) {
if (! (s <= checkString(MACHINE, 'string-ci<=?', i).toString().toUpperCase())) {
return false;
}
}
return true;
});
installPrimitiveProcedure(
'string-ci<?',
baselib.arity.makeArityAtLeast(1),
function (MACHINE) {
var s = checkString(MACHINE, 'string-ci<?', 0).toString().toUpperCase();
var i;
for (i = 1; i < MACHINE.argcount; i++) {
if (! (s < checkString(MACHINE, 'string-ci<?', i).toString().toUpperCase())) {
return false;
}
}
return true;
});
installPrimitiveProcedure(
'string-ci>=?',
baselib.arity.makeArityAtLeast(1),
function (MACHINE) {
var s = checkString(MACHINE, 'string-ci>=?', 0).toString().toUpperCase();
var i;
for (i = 1; i < MACHINE.argcount; i++) {
if (! (s >= checkString(MACHINE, 'string-ci>=?', i).toString().toUpperCase())) {
return false;
}
}
return true;
});
installPrimitiveProcedure(
'string-ci>?',
baselib.arity.makeArityAtLeast(1),
function (MACHINE) {
var s = checkString(MACHINE, 'string-ci>?', 0).toString().toUpperCase();
var i;
for (i = 1; i < MACHINE.argcount; i++) {
if (! (s > checkString(MACHINE, 'string-ci>?', i).toString().toUpperCase())) {
return false;
}
}
return true;
});
installPrimitiveProcedure(
'string-append',
baselib.arity.makeArityAtLeast(0),

View File

@ -365,15 +365,16 @@ memq
string-length
string-ref
string=?
;; string-ci=?
;; string<?
;; string>?
;; string<=?
;; string>=?
;; string-ci<?
;; string-ci>?
;; string-ci<=?
;; string-ci>=?
string<?
string>?
string<=?
string>=?
string-ci=?
string-ci<?
string-ci>?
string-ci<=?
string-ci>=?
substring
string-append
string->list

View File

@ -30,3 +30,10 @@
(string->list "xyz")
(string->list "x")
(string->list "")
(string<? "" "")
(string<? "hello" "Hello")
(string<? "hello" "hello")
(string<? "hello" "hi")
(string<? "hello" "he")