mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-23 13:23:47 +00:00
Estimated hours taken: 0.25 tests/hard_coded: Add a test case for functions and predicates with the same name whose arity differs by only one.
37 lines
912 B
Mathematica
37 lines
912 B
Mathematica
%----------------------------------------------------------------------------
|
|
% Small test of functions and predicates that have the same name.
|
|
%----------------------------------------------------------------------------
|
|
|
|
:- module func_and_pred.
|
|
|
|
:- interface.
|
|
|
|
:- import_module list, io.
|
|
|
|
:- func concat(list(X), list(X)) = list(X).
|
|
:- mode concat(in, in) = out is det.
|
|
|
|
:- pred concat(list(X), list(X), list(X)).
|
|
:- mode concat(in, in, out) is det.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module string.
|
|
|
|
concat([], L) = L.
|
|
concat([E|R], L) = [E|concat(R,L)].
|
|
|
|
concat([], L, L).
|
|
concat([E|R], L, [E|Z]) :-
|
|
concat(R,L,Z).
|
|
|
|
main -->
|
|
{ concat(['H','e'],['l','l','o',' '], Hello) },
|
|
{ World = concat(['w','o'],['r','l','d','!','\n']) },
|
|
{ string__from_char_list(concat(Hello, World), HelloWorld) },
|
|
io__write_string(HelloWorld).
|
|
|
|
%-----------------------------
|