diff options
| -rw-r--r-- | rosetta/lev.neb | 15 | ||||
| -rw-r--r-- | 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) |
