From f3a69989fad4658cba850ea6134e2a59ef596b07 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 15 Dec 2021 14:39:13 -0500 Subject: [PATCH] Better switch functionality. --- src/examples/lib.pbl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/examples/lib.pbl b/src/examples/lib.pbl index 2230342..1f04c77 100644 --- a/src/examples/lib.pbl +++ b/src/examples/lib.pbl @@ -28,10 +28,9 @@ ; Switch expression ; Doesn't yet work with lambdas (def switch (fn (val pair_list) - (if (= 0 (len pair_list)) "no match" ( - (def current (at 0 pair_list)) - (if (= val (at 0 current)) (at 1 current) ( + (if (= 0 (len pair_list)) "no match" + (if (= val (at 0 (at 0 pair_list))) (at 1 (at 0 pair_list)) ( (switch val (rest pair_list)) )) - )) + ) ))