tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit 7d3c9c42c1e6a7f1cbf20ebbb55ed4a09874f3c9
parent ce3ca33ab6b2bc064eb52dcbf77e43885a9e0e58
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Sat,  9 Jan 2021 15:01:45 -0800

Fix get numerator and denominator

Diffstat:
test.c | 10+++++-----
tisp.c | 4++--
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/test.c b/test.c @@ -135,11 +135,11 @@ char *tests[][2] = { { "(get '(dirty-burger freedom-35) 'cdr)", "(freedom-35)" }, { "(get '(1 2 3 4) 'cdr)", "(2 3 4)" }, { "(get '(2 4 6) 'car)", "2" }, - { "(get 3 'num)", "3" }, - { "(get 83 'den)", "1" }, - { "(get 3/2 'den)", "2" }, - { "(get 10/15 'den)", "3" }, - { "(get 9/2 'num)", "9" }, + { "(get 3 'numerator)", "3" }, + { "(get 83 'denominator)", "1" }, + { "(get 3/2 'denominator)", "2" }, + { "(get 10/15 'denominator)", "3" }, + { "(get 9/2 'numerator)", "9" }, { "eq", NULL }, { "(=)", "True" }, diff --git a/tisp.c b/tisp.c @@ -902,9 +902,9 @@ prim_get(Tsp st, Hash env, Val args) break; case TSP_INT: case TSP_RATIO: - if (!strncmp(prop->v.s, "numerator", 3)) + if (!strncmp(prop->v.s, "numerator", 9)) return mk_int(v->v.n.num); - if (!strncmp(prop->v.s, "denominator", 3)) + if (!strncmp(prop->v.s, "denominator", 9)) return mk_int(v->v.n.den); break; case TSP_PAIR: /* TODO get nth element if number */