klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 28dbb9c6e746e9b6cd942b33ac63e662efa6429f
parent 4f05c8ff1137f58b0d9732604d18bf39cc763947
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Sun, 20 Mar 2011 03:30:31 -0300

Added zero? to the ground environment.

Diffstat:
Msrc/kgnumbers.c | 6++++++
Msrc/kgnumbers.h | 7+++++++
Msrc/kground.c | 4++++
3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/kgnumbers.c b/src/kgnumbers.c @@ -221,3 +221,9 @@ void kminus(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) return; } } + +/* 12.5.7 zero? */ +/* uses ftyped_predp */ + +/* Helper for zero? */ +bool kzerop(TValue n) { return kfast_zerop(n); } diff --git a/src/kgnumbers.h b/src/kgnumbers.h @@ -56,6 +56,13 @@ void ktimes(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); /* TEMP: for now only accept two arguments */ void kminus(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); +/* 12.5.7 zero? */ +/* uses ftyped_predp */ + +/* Helper for zero? */ +bool kzerop(TValue n); + + /* Misc Helpers */ inline bool kfast_zerop(TValue n) { return ttisfixint(n) && ivalue(n) == 0; } /* TEMP: only exact infinties */ diff --git a/src/kground.c b/src/kground.c @@ -517,6 +517,10 @@ void kinit_ground_env(klisp_State *K) /* TEMP: for now only accept two arguments */ add_applicative(K, ground_env, "-", kminus, 0); + /* 12.5.7 zero? */ + add_applicative(K, ground_env, "zero?", ftyped_predp, 3, symbol, + p2tv(knumberp), p2tv(kzerop)); + /* ... TODO */ /*