From cffc6bff847120d71b25d9cb424b27704000aec5 Mon Sep 17 00:00:00 2001 From: mryouse Date: Sun, 4 Jun 2023 02:47:06 +0000 Subject: fixes --- rosetta/lev.neb | 15 +++++++++------ rosetta/palindrome.neb | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/rosetta/lev.neb b/rosetta/lev.neb index 6797c41..03db260 100644 --- a/rosetta/lev.neb +++ b/rosetta/lev.neb @@ -1,9 +1,12 @@ -(func min (lst :{:int}) - (def val (first lst)) - (for-each (rest lst) - (if (< _item_ val) - (redef val _item_))) - val) +; this should be in the stdlib +(func min (lst) + (reduce + (lambda (acc x) + (if (< x acc) + x + acc)) + (rest lst) + (first lst))) (func lev (s t) (branch diff --git a/rosetta/palindrome.neb b/rosetta/palindrome.neb index 198456d..3f8bf8d 100644 --- a/rosetta/palindrome.neb +++ b/rosetta/palindrome.neb @@ -1,3 +1,4 @@ +; the answer in p99/p06 is better (func palindrome? (str) (branch ((<= (length str) 1) #true) -- cgit v1.2.3