From 6ceb57bf7d46654aa411042b2e07c3f5c2df1b34 Mon Sep 17 00:00:00 2001 From: cynic Date: Wed, 19 Oct 2022 08:22:41 -0400 Subject: [PATCH] use buttifool `loop` function instead of ugly macro --- lib/loop.klambda | 14 ++++++-------- test.klambda | 6 ++++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/loop.klambda b/lib/loop.klambda index f870e65..b18c20a 100644 --- a/lib/loop.klambda +++ b/lib/loop.klambda @@ -1,8 +1,6 @@ -DEFINE:loop:(def loop (lambda (counter max)\ - (all\ - statement\ - (cond (= counter max)\ - counter\ - (loop (+ counter 1) max)))))\ -(loop start end)\ -:start:end:statement +(def loop (lambda (max i statement) + (all + statement + (cond (= i max) + false + (loop max (- i 1) (id statement)))))) \ No newline at end of file diff --git a/test.klambda b/test.klambda index 0cab6a5..013d667 100644 --- a/test.klambda +++ b/test.klambda @@ -15,9 +15,11 @@ INCLUDE:./lib/aids.klambda "adult (hag)" "not adult (uoh)")) -loop:0:100:(spit (cond (% counter 15) (cond (% counter 5) (cond (% counter 3) counter "fizz") "buzz") "fizzbuzz")) +(loop 0 100 + (id spit (cond (% i 15) (cond (% i 5) (cond (% i 3) i "fizz") "buzz") "fizzbuzz"))) (def moeblob ("moe" "moe~" "kyun!!")) -loop:0:(- (length moeblob) 1):(spit (at counter moeblob)) +(loop 0 (- (length moeblob) 1) + (id spit (at i moeblob))) (thesis) \ No newline at end of file