aboutsummaryrefslogtreecommitdiff
path: root/rosetta/lev.neb
blob: 6797c418ee5f882c572e64da829152ac02bc5d29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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))))))))