Prolog "hiord"
/**
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies AG makes no warranties
* regarding the provided information. XLOG Technologies AG assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies AG.
*
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies AG. If the company was not the originator of some
* excerpts, XLOG Technologies AG has at least obtained the right to
* reproduce, change and translate the information.
*
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
*
* Restrictions
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
*
* Trademarks
* Jekejeke is a registered trademark of XLOG Technologies AG.
*/
runner_file(extend, hiord, 'XLOG 3.5 hiord').
/* call(C, X, Y) */
makepair(X, Y, X-Y).
runner_pred(call, 3, extend, hiord, 'Corr.2 8.15.4.4').
runner_case(call, 3, extend, hiord, 'Corr.2 8.15.4.4, ISO 1') :-
call(integer, 3).
runner_case(call, 3, extend, hiord, 'Corr.2 8.15.4.4, ISO 2') :-
call(functor(F, c), 0),
F == c.
runner_case(call, 3, extend, hiord, 'Corr.2 8.15.4.4, ISO 4') :-
findall(X, call(;, X=1, X=2), L),
L == [1,2].
runner_case(call, 3, extend, hiord, 'Corr.2 8.15.4.4, XLOG 1') :-
call(call(call(makepair,1),2),X),
X == 1-2.
runner_case(call, 3, extend, hiord, 'Corr.2 8.15.4.4, XLOG 2') :-
catch(call(',', integer(1), 3), error(E,_), true),
E == type_error(callable, 3).
/* free_variables(Q, L, G) */
runner_pred(free_variables,3, extend, hiord, 'ISO 7.1.1.4').
runner_case(free_variables,3, extend, hiord, 'ISO 7.1.1.4, ISO 1') :-
free_variables(f(Z)^(X+Y+Z), L, G),
L == [X, Y], G == X+Y+Z.
runner_case(free_variables,3, extend, hiord, 'ISO 7.1.1.4, ISO 2') :-
free_variables(A^Z^(A+X+Y+Z), L, G),
L == [X, Y], G == A+X+Y+Z.
runner_case(free_variables,3, extend, hiord, 'ISO 7.1.1.4, ISO 3') :-
\+ current_prolog_flag(dialect, gprolog),
X = f(g(A,X),B), free_variables(X, L, G),
L == [A, B], G == X.
runner_case(free_variables,3, extend, hiord, 'ISO 7.1.1.4, ISO 4') :-
\+ current_prolog_flag(dialect, gprolog),
X = f(g(A,X),B), Y = h(Y,B), free_variables(Y^X, L, G),
L == [A], G == X.
/* =>(X, G, Y) */
lloyd((X,Y) => Y is X+1).
runner_pred(=>, 3, extend, hiord, 'XLOG 3.5.1').
runner_case(=>, 3, extend, hiord, 'XLOG 3.5.1, XLOG 1') :-
call((X,Y) => Y is X+1, 1, Z),
Z == 2.
runner_case(=>, 3, extend, hiord, 'XLOG 3.5.1, XLOG 2') :-
\+ call(X => Y => Y is X+1, 1, _).
runner_case(=>, 3, extend, hiord, 'XLOG 3.5.1, XLOG 3') :-
call(X => X = [1,D,3], Y),
Y == [1,D,3].
runner_case(=>, 3, extend, hiord, 'XLOG 3.5.1, XLOG 4') :-
call(X => D^(X = [1,D,3]), Y),
Y = [1,E,3], E \== D.
runner_case(=>, 3, extend, hiord, 'XLOG 3.5.1, XLOG 5') :-
lloyd(C),
\+ C = (_ => _) .
runner_case(=>, 3, extend, hiord, 'XLOG 3.5.1, XLOG 6') :-
lloyd(C), call(C, 1, Z),
Z == 2.
runner_case(=>, 3, extend, hiord, 'XLOG 3.5.1, XLOG 7') :-
lloyd(C), \+ call(C, 1, _, _).
/* maplist(C, L, R) */
funplus(X, Y, Z) :- Z is X+Y.
runner_pred(maplist, 3, extend, hiord, 'N235 7.4').
runner_case(maplist, 3, extend, hiord, 'N235 7.4, XLOG 1') :-
maplist(funplus(1), [2,3,4], X),
X == [3, 4, 5].
runner_case(maplist, 3, extend, hiord, 'N235 7.4, XLOG 2') :-
findall(X-Y, maplist(between(1,2), [X,Y]), L),
L == [1-1, 1-2, 2-1, 2-2].
runner_case(maplist, 3, extend, hiord, 'N235 7.4, XLOG 3') :-
\+ maplist(=, [1,2,3], [1,2]).
runner_case(maplist, 3, extend, hiord, 'N235 7.4, XLOG 4') :-
catch(maplist(char_code, [a,1,c], _), error(E,_), true),
E == type_error(atom, 1).
/* foldl(C, L, R, I, O) */
binact --> [0].
binact --> [1].
runner_pred(foldl, 5, extend, hiord, 'XLOG 3.5.2').
runner_case(foldl, 5, extend, hiord, 'XLOG 3.5.2, XLOG 1') :-
foldl(funplus, [1,2,3], 0, X),
X == 6.
runner_case(foldl, 5, extend, hiord, 'XLOG 3.5.2, XLOG 2') :-
findall(X, foldl(call, [binact, binact], X, []), L),
L == [[0, 0], [0, 1], [1, 0], [1, 1]].
runner_case(foldl, 5, extend, hiord, 'XLOG 3.5.2, XLOG 3') :-
\+ foldl(call, [=,=], 1, 2).
runner_case(foldl, 5, extend, hiord, 'XLOG 3.5.2, XLOG 4') :-
catch(foldl(atom_concat, [abc,1,def], '', _), error(E,_), true),
E == type_error(atom, 1).
/* filter(C, L, R) */
haselem(L, X) :- member(X, L).
runner_pred(filter, 3, extend, hiord, 'XLOG 3.5.3').
runner_case(filter, 3, extend, hiord, 'XLOG 3.5.3, XLOG 1') :-
filter(<(3), [1,2,3,4,5], X),
X == [4, 5].
runner_case(filter, 3, extend, hiord, 'XLOG 3.5.3, XLOG 2') :-
filter(haselem([3,4,5]), [1,2,3], X),
X == [3].