Rewrite func "not" in Lisp
This commit is contained in:
parent
baf566703e
commit
ad7a80752a
1
Makefile
1
Makefile
|
@ -20,6 +20,7 @@ OBJS = \
|
||||||
|
|
||||||
LIBS = \
|
LIBS = \
|
||||||
-r lib/lists.scm \
|
-r lib/lists.scm \
|
||||||
|
-r lib/logic.scm \
|
||||||
-r lib/io.scm \
|
-r lib/io.scm \
|
||||||
-r lib/type_predicates.scm
|
-r lib/type_predicates.scm
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
(define (not x) (if x #false #true))
|
|
@ -31,8 +31,6 @@ static struct Object *func_equal_QN(size_t args_count, struct Object **args_arra
|
||||||
static struct Object *func_number_TO_string(size_t args_count, struct Object **args_array);
|
static struct Object *func_number_TO_string(size_t args_count, struct Object **args_array);
|
||||||
static struct Object *func_string_TO_symbol(size_t args_count, struct Object **args_array);
|
static struct Object *func_string_TO_symbol(size_t args_count, struct Object **args_array);
|
||||||
static struct Object *func_symbol_TO_string(size_t args_count, struct Object **args_array);
|
static struct Object *func_symbol_TO_string(size_t args_count, struct Object **args_array);
|
||||||
// Logical operators
|
|
||||||
static struct Object *func_not(size_t args_count, struct Object **args_array);
|
|
||||||
// Arithmetic operators
|
// Arithmetic operators
|
||||||
static struct Object *func_EQ(size_t args_count, struct Object **args_array);
|
static struct Object *func_EQ(size_t args_count, struct Object **args_array);
|
||||||
static struct Object *func_PLUS(size_t args_count, struct Object **args_array);
|
static struct Object *func_PLUS(size_t args_count, struct Object **args_array);
|
||||||
|
@ -62,8 +60,6 @@ static struct Object builtins[] = {
|
||||||
{ .type = TYPE_PROCEDURE, .procedure = { "number->string", func_number_TO_string } },
|
{ .type = TYPE_PROCEDURE, .procedure = { "number->string", func_number_TO_string } },
|
||||||
{ .type = TYPE_PROCEDURE, .procedure = { "string->symbol", func_string_TO_symbol } },
|
{ .type = TYPE_PROCEDURE, .procedure = { "string->symbol", func_string_TO_symbol } },
|
||||||
{ .type = TYPE_PROCEDURE, .procedure = { "symbol->string", func_symbol_TO_string } },
|
{ .type = TYPE_PROCEDURE, .procedure = { "symbol->string", func_symbol_TO_string } },
|
||||||
// Logical operators
|
|
||||||
{ .type = TYPE_PROCEDURE, .procedure = { "not", func_not } },
|
|
||||||
// Arithmetic operators
|
// Arithmetic operators
|
||||||
{ .type = TYPE_PROCEDURE, .procedure = { "=", func_EQ } },
|
{ .type = TYPE_PROCEDURE, .procedure = { "=", func_EQ } },
|
||||||
{ .type = TYPE_PROCEDURE, .procedure = { "+", func_PLUS } },
|
{ .type = TYPE_PROCEDURE, .procedure = { "+", func_PLUS } },
|
||||||
|
@ -455,18 +451,6 @@ struct Object *func_symbol_TO_string(
|
||||||
return Object_new_string(symbol->s);
|
return Object_new_string(symbol->s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************
|
|
||||||
* Logical operators *
|
|
||||||
*********************/
|
|
||||||
|
|
||||||
struct Object *func_not(
|
|
||||||
const size_t args_count,
|
|
||||||
struct Object **const args_array
|
|
||||||
) {
|
|
||||||
assert(args_count == 1);
|
|
||||||
return Object_new_boolean(Object_is_false(args_array[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
* Arithmetic operators *
|
* Arithmetic operators *
|
||||||
************************/
|
************************/
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
(assert-true (procedure? (arcana/builtin 'number->string)))
|
(assert-true (procedure? (arcana/builtin 'number->string)))
|
||||||
(assert-true (procedure? (arcana/builtin 'string->symbol)))
|
(assert-true (procedure? (arcana/builtin 'string->symbol)))
|
||||||
(assert-true (procedure? (arcana/builtin 'symbol->string)))
|
(assert-true (procedure? (arcana/builtin 'symbol->string)))
|
||||||
; Logical operators
|
|
||||||
(assert-true (procedure? (arcana/builtin 'not)))
|
|
||||||
; Arithmetic operators
|
; Arithmetic operators
|
||||||
(assert-true (procedure? (arcana/builtin '=)))
|
(assert-true (procedure? (arcana/builtin '=)))
|
||||||
(assert-true (procedure? (arcana/builtin '+)))
|
(assert-true (procedure? (arcana/builtin '+)))
|
||||||
|
|
Loading…
Reference in New Issue