From a39c8eb3cd37b3ef78703ddd7eacbe60246cb508 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Fri, 21 Feb 2020 07:55:17 -0800 Subject: [PATCH] Haha oops; no negative numbers in microscheme. --- menelaus.scm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/menelaus.scm b/menelaus.scm index 60e0939..d856fd7 100644 --- a/menelaus.scm +++ b/menelaus.scm @@ -23,8 +23,12 @@ lst (member v (cdr lst))))) +;; we need a numeric value to represent not-found; microscheme only has unsigned +;; ints but this will still get us a reasonable not-found value +(define not-found (- 0 1)) + (define (find-aux v x n max) - (if (= x (or (vector-ref v n) (- 0 1))) + (if (= x (or (vector-ref v n) not-found)) n (if (= n max) #f @@ -93,7 +97,7 @@ (define (remove-last-down-aux key n) (if (< n 9) - (if (= key (or (vector-ref last-keys-down n) -1)) + (if (equal? key (vector-ref last-keys-down n)) (vector-set! last-keys-down n #f) (remove-last-down-aux key (+ n 1))) #f))