default.txt 515 B

123456789101112131415161718192021222324
  1. % "Hello World" in Mercury.
  2. :- module hello.
  3. :- interface.
  4. :- import_module io.
  5. :- pred main(io::di, io::uo) is det.
  6. :- implementation.
  7. main(!IO) :-
  8. io.write_string("Hello, world\n", !IO).
  9. :- pred filter(pred(T), list(T), list(T), list(T) ).
  10. :- mode filter(in(pred(in) is semidet), in, out, out ) is det.
  11. filter(_, [], [], []).
  12. filter(P, [X | Xs], Ys, Zs) :-
  13. filter(P, Xs, Ys0, Zs0),
  14. ( if P(X) then Ys = [X | Ys0], Zs = Zs0
  15. else Ys = Ys0 , Zs = [X | Zs0]
  16. ).