Added real? and integer?

This commit is contained in:
Justin Ethier 2015-04-09 17:54:35 -04:00
parent f12094cae1
commit b2cc35e141
6 changed files with 27 additions and 1 deletions

View file

@ -468,6 +468,8 @@
((eq? p 'char?) "Cyc_is_char")
((eq? p 'null?) "Cyc_is_null")
((eq? p 'number?) "Cyc_is_number")
((eq? p 'real?) "Cyc_is_real")
((eq? p 'integer?) "Cyc_is_integer")
((eq? p 'pair?) "Cyc_is_cons")
((eq? p 'procedure?) "Cyc_is_procedure")
((eq? p 'string?) "Cyc_is_string")

View file

@ -263,6 +263,8 @@
(list 'eof-object? eof-object?)
(list 'null? null?)
(list 'number? number?)
(list 'real? real?)
(list 'integer? integer?)
(list 'pair? pair?)
(list 'procedure? procedure?)
(list 'string? string?)

View file

@ -86,6 +86,8 @@ static object Cyc_is_boolean(object o);
static object Cyc_is_cons(object o);
static object Cyc_is_null(object o);
static object Cyc_is_number(object o);
static object Cyc_is_real(object o);
static object Cyc_is_integer(object o);
static object Cyc_is_symbol(object o);
static object Cyc_is_string(object o);
static object Cyc_is_char(object o);
@ -528,6 +530,16 @@ static object Cyc_is_number(object o){
return boolean_t;
return boolean_f;}
static object Cyc_is_real(object o){
if (!nullp(o) && !is_value_type(o) && type_of(o) == double_tag)
return boolean_t;
return boolean_f;}
static object Cyc_is_integer(object o){
if (!nullp(o) && !is_value_type(o) && type_of(o) == integer_tag)
return boolean_t;
return boolean_f;}
static object Cyc_is_symbol(object o){
if (!nullp(o) && !is_value_type(o) && ((list)o)->tag == symbol_tag)
return boolean_t;
@ -927,6 +939,10 @@ static void _eof_91object_127(object cont, object args) {
return_funcall1(cont, Cyc_is_eof_object(car(args))); }
static void _number_127(object cont, object args) {
return_funcall1(cont, Cyc_is_number(car(args))); }
static void _real_127(object cont, object args) {
return_funcall1(cont, Cyc_is_real(car(args))); }
static void _integer_127(object cont, object args) {
return_funcall1(cont, Cyc_is_integer(car(args))); }
static void _pair_127(object cont, object args) {
return_funcall1(cont, Cyc_is_cons(car(args))); }
static void _procedure_127(object cont, object args) {
@ -1122,6 +1138,8 @@ defprimitive(char_127, char?, &_char_127); /* char? */
defprimitive(eof_91object_127, eof-object?, &_eof_91object_127); /* eof-object? */
defprimitive(null_127, null?, &_null_127); /* null? */
defprimitive(number_127, number?, &_number_127); /* number? */
defprimitive(real_127, real?, &_real_127); /* real? */
defprimitive(integer_127, integer?, &_integer_127); /* integer? */
defprimitive(pair_127, pair?, &_pair_127); /* pair? */
defprimitive(procedure_127, procedure?, &_procedure_127); /* procedure? */
defprimitive(string_127, string?, &_string_127); /* string? */

View file

@ -1,3 +1,4 @@
1.1
;((lambda (x)
; ((lambda ()
; ((lambda (z)

View file

@ -158,7 +158,7 @@
(assert:equal "" (string->number "0") 0)
(assert:equal "" (string->number "42") 42)
;(assert:equal "" (string->number "343243243232") ;; Note no bignum support
(assert:equal "" (string->number "3.14159") 3) ;; Currently no float support
(assert:equal "" (string->number "3.14159") 3.14159)
(assert:equal "" (list->string (list #\A #\B #\C)) "ABC")
(assert:equal "" (list->string (list #\A)) "A")
(assert:equal "" (list->string (list)) "")

View file

@ -511,6 +511,7 @@
; const? : exp -> boolean
(define (const? exp)
(or (integer? exp)
(real? exp)
(string? exp)
(char? exp)
(boolean? exp)))
@ -735,6 +736,8 @@
eof-object?
null?
number?
real?
integer?
pair?
procedure?
string?