more support for some character stuff
This commit is contained in:
parent
1a63f418ac
commit
cba2b31e45
9
examples/read-bytes.rkt
Normal file
9
examples/read-bytes.rkt
Normal file
|
@ -0,0 +1,9 @@
|
|||
#lang planet dyoo/whalesong
|
||||
|
||||
(let loop ([b (read-byte)])
|
||||
(cond
|
||||
[(eof-object? b)
|
||||
(void)]
|
||||
[else
|
||||
(display (string (integer->char b)))
|
||||
(loop (read-byte))]))
|
|
@ -124,6 +124,7 @@
|
|||
cleanupAndContinue();
|
||||
});
|
||||
MACHINE.params['currentDisplayer'](MACHINE, textFieldDiv.get(0));
|
||||
readLine.focus();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -75,6 +75,17 @@
|
|||
var checkNatural = baselib.check.checkNatural;
|
||||
var checkNaturalInRange = baselib.check.checkNaturalInRange;
|
||||
var checkInteger = baselib.check.checkInteger;
|
||||
var checkIntegerForChar = baselib.check.makeCheckArgumentType(
|
||||
function(x) {
|
||||
return (baselib.numbers.isInteger(x) &&
|
||||
((baselib.numbers.lessThanOrEqual(0, x) &&
|
||||
baselib.numbers.lessThanOrEqual(x, 55295))
|
||||
||
|
||||
(baselib.numbers.lessThanOrEqual(57344, x) &&
|
||||
baselib.numbers.lessThanOrEqual(x, 1114111))));
|
||||
},
|
||||
'integer'
|
||||
);
|
||||
var checkRational = baselib.check.checkRational;
|
||||
var checkPair = baselib.check.checkPair;
|
||||
var checkList = baselib.check.checkList;
|
||||
|
@ -1081,6 +1092,15 @@
|
|||
});
|
||||
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'integer->char',
|
||||
1,
|
||||
function(M) {
|
||||
var ch = baselib.numbers.toFixnum(checkIntegerForChar(M, 'integer->char', 0));
|
||||
return baselib.chars.makeChar(String.fromCharCode(ch));
|
||||
});
|
||||
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'char-upcase',
|
||||
1,
|
||||
|
@ -1290,7 +1310,12 @@
|
|||
});
|
||||
|
||||
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'eof-object?',
|
||||
1,
|
||||
function(M) {
|
||||
return M.e[M.e.length -1] === baselib.constants.EOF_VALUE;
|
||||
});
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'number?',
|
||||
|
|
|
@ -450,7 +450,7 @@ char=?
|
|||
;; char-upper-case?
|
||||
;; char-lower-case?
|
||||
;; char->integer
|
||||
;; integer->char
|
||||
integer->char
|
||||
char-upcase
|
||||
char-downcase
|
||||
|
||||
|
@ -469,7 +469,7 @@ char=?
|
|||
make-placeholder
|
||||
placeholder-set!
|
||||
|
||||
|
||||
eof-object?
|
||||
read-byte)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user