diff options
| author | mryouse | 2023-06-03 20:22:18 +0000 |
|---|---|---|
| committer | mryouse | 2023-06-03 20:22:18 +0000 |
| commit | 7b7bf727da3250907284368b98b0083a4b4e2386 (patch) | |
| tree | 34802caea5181dc0fb97992746ab99b080448418 /rosetta/lev.neb | |
initial commit
Diffstat (limited to 'rosetta/lev.neb')
| -rw-r--r-- | rosetta/lev.neb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/rosetta/lev.neb b/rosetta/lev.neb new file mode 100644 index 0000000..6797c41 --- /dev/null +++ b/rosetta/lev.neb @@ -0,0 +1,20 @@ +(func min (lst :{:int}) + (def val (first lst)) + (for-each (rest lst) + (if (< _item_ val) + (redef val _item_))) + val) + +(func lev (s t) + (branch + ((eq? 0 (length s)) (length t)) + ((eq? 0 (length t)) (length s)) + ((eq? (first s) (first t)) + (lev (rest s) (rest t))) + (#true + (+ 1 + (min + (list + (lev s (rest t)) + (lev (rest s) t) + (lev (rest s) (rest t)))))))) |
