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

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



{----------------------------------------------------------------}
{--- My attempt at a translation of the Haskell 1.1           ---}
{--- list prelude, "module PreludeList".                      ---}
{----------------------------------------------------------------}

list a ::= Nil | Cons a (list a); 

pair a b ::= Pair a b;

;;

{--------------------------------------------------------}

zipWith z al bl
= case al of
    Cons a as -> case bl of
                   Cons b bs -> Cons (z a b) (zipWith z as bs);
                   Nil -> Nil
                 end;
    Nil -> Nil
  end;

{--------------------------------------------------------}
{xxx = zipWith (letrec f = \a b -> f a b in f);}

zip
= zipWith (\a b -> Pair a b);

zip2 al bl
= case al of
    Cons a as -> case bl of
                   Cons b bs -> Cons (Pair a b) (zip2 as bs);
                   Nil -> Nil
                 end;
    Nil -> Nil
  end;

{----------------------------------------------------------------}
{--- end                                      preludeList.cor ---}
{----------------------------------------------------------------}

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.