From 0dc4f9c62bf26b373284e7d27aa41c500c8bd16a Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 11 Jun 2021 21:36:12 -0700 Subject: [PATCH] hacky bugfix: support floats in nth Needed because we don't yet have a primitive in the shell to truncate/round non-integers to integers. Before: (nth (/ 31 10) # we don't have float literals yet '(1 2 3 4)) => NULL ..with an unpleasant abort likely later on. Really the correct thing to do is ensure none of my primitives ever returns NULL. Start with car/cdr. --- shell/data.limg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/data.limg b/shell/data.limg index 21488812..9d130a28 100644 --- a/shell/data.limg +++ b/shell/data.limg @@ -22,7 +22,7 @@ 0 (+ 1 (len (cdr l)))))]) (nth . [(def (nth n xs) - (if (<= n 0) + (if (< n 1) (car xs) (nth (- n 1) (cdr xs))))]) (map1 . [(def (map1 f xs)