Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/tests/nofib/real/anna/bug.cor

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


list a ::= Nil | Cons a (list a);
tree a ::= Leaf | Branch (tree a) a (tree a);
;;

insert x t = case t of
                Leaf -> Branch Leaf x Leaf;
                Branch l x1 r ->
                 case x==x1 of
                    True -> Branch l x1 r;
                    False -> case x<x1 of
                                True -> Branch (insert x l) x1 r;
                                False -> Branch l x1 (insert x r)
                             end
                 end
            end;

listToTree l =
   letrec ltt = \tr li -> case li of
                             Nil -> tr;
                             Cons x xs -> ltt (insert x tr) xs
                          end
   in ltt Leaf l;

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.