Files
mercury/tests/general/higher_order.m
Tyson Dowd 630c98c8f1 Remove support for term_to_type and type_to_term implemented as special
Estimated hours taken: 5

Remove support for term_to_type and type_to_term implemented as special
preds.  Remove support for one-cell and one-or-two-cell type_infos (now
shared-one-or-two-cell type_infos). Move definitions that were in
mercury_builtin.m back to where they belong.

This code has been removed because it is no longer used, and was no
longer being maintained but was still quite complex.

tests/general/disj_disj.m:
tests/general/dnf.m:
tests/general/higher_order.m:
tests/general/nondet_disj.m:
tests/hard_coded/cc_nondet_disj.m:
tests/hard_coded/pragma_inline.m:
tests/invalid/funcs_as_preds.err_exp:
tests/misc_tests/mdemangle_test.exp:
tests/valid/agc_unbound_typevars.m:
tests/valid/middle_rec_labels.m:
tests/valid/subtype_switch.m:
tests/warnings/infinite_recursion.m:
	Import module `list' or `term' (or both).
1997-05-20 02:09:15 +00:00

57 lines
1.2 KiB
Mathematica

% File: higher_order.m.
% Author: fjh.
%
% Some very basic tests of higher-order predicates and lambda expressions.
:- module higher_order.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module string, list.
:- pred map(pred(T1, T2), list(T1), list(T2)).
:- mode map(pred(in, out) is det, in, out) is det.
:- mode map(pred(in, in) is semidet, in, in) is semidet.
higher_order__map(_Pred, [], []).
higher_order__map(Pred, [X|Xs], [Y|Ys]) :-
call(Pred, X, Y),
higher_order__map(Pred, Xs, Ys).
:- pred double(string::in, string::out) is det.
double(X, Y) :-
string__append(X, X, Y).
main -->
{ higher_order__map(double, ["foo", "bar"], List) },
io__write_strings(List),
io__write_string("\n"),
(
{ higher_order__map(lambda([X::in, Y::in] is semidet,
double(X, Y)), ["ab"], ["abab"]) }
->
io__write_string("Yes\n")
;
io__write_string("Oops\n")
),
(
{ higher_order__map(lambda([X::in, Y::in] is semidet,
double(X, Y)), ["ab"], ["abracadabra"]) }
->
io__write_string("Oops\n")
;
io__write_string("No\n")
),
(
{ higher_order__map(lambda([X::in, Y::in] is semidet,
double(X, Y)), ["ab"], []) }
->
io__write_string("Oops\n")
;
io__write_string("No\n")
).