Prolog "update"
Admin User, erstellt 07. Apr. 2025
/**
* 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(extra, update, 'XLOG 3.5 terms').
/****************************************************************/
/* terms.p extras */
/****************************************************************/
/* change_arg(K, X, Y) */
/* Dogelog Player variant without functor/3 */
runner_pred(change_arg,3, extra, update, 'XLOG 3.5.1').
runner_case(change_arg,3, extra, update, 'XLOG 3.5.1, XLOG 1') :-
H = foo(_,_), change_arg(1, H, a), change_arg(2, H, b),
H == foo(a, b).
runner_case(change_arg,3, extra, update, 'XLOG 3.5.1, XLOG 2') :-
H = foo(_,_), change_arg(1, H, a), change_arg(2, H, b),
change_arg(2, H, c), H == foo(a, c).
runner_case(change_arg,3, extra, update, 'XLOG 3.5.1, XLOG 3') :-
H = foo(_,_), change_arg(1, H, a), change_arg(2, H, b),
change_arg(2, H, c), change_arg(1, H, d), H == foo(d, c).
runner_case(change_arg,3, extra, update, 'XLOG 3.5.1, XLOG 4') :-
H = foo(_,_), change_arg(1, H, a), change_arg(2, H, b),
(change_arg(2, H, c), fail; change_arg(1, H, d)), H == foo(d, c).
runner_case(change_arg,3, extra, update, 'XLOG 3.5.1, XLOG 5') :-
H = foo(_), change_arg(1, H, a),
(copy_term(f(X,g(X,Y),Y), T), change_arg(1, H, T), fail; true),
H = foo(f(X1,g(X2,X3),X4)), var(X1), var(X2), var(X3), var(X4).
runner_case(change_arg,3, extra, update, 'XLOG 3.5.1, XLOG 6') :-
H = foo(_), change_arg(1, H, a),
(copy_term(f(X,g(X,Y),Y), T), change_arg(1, H, T), fail; true),
H = foo(f(X1,g(X2,X3),X4)), X1 == X2, X3 == X4, X1 \== X3.
runner_case(change_arg,3, extra, update, 'XLOG 3.5.1, ISO 6') :-
\+ change_arg(0, foo(a, b), _).
runner_case(change_arg,3, extra, update, 'XLOG 3.5.1, ISO 8') :-
catch(change_arg(1.2, foo(a,b), a), error(E,_), true),
E == type_error(integer, 1.2).
runner_case(change_arg,3, extra, update, 'XLOG 3.5.1, ISO 9') :-
catch(change_arg(1, _, a), error(E, _), true),
E == instantiation_error.
runner_case(change_arg,3, extra, update, 'XLOG 3.5.1, XLOG 7') :-
\+ change_arg(9, atom, _).
runner_case(change_arg,3, extra, update, 'XLOG 3.5.1, XLOG 8') :-
H = foo(_), arg(1, H, a),
catch(change_arg(1, H, b), error(E,_), true),
E = type_error(conductor, a).
/****************************************************************/
/* Object Specials */
/****************************************************************/
sample_object(X) :-
ir_object_new(X),
ir_object_set(X, foo, 123),
ir_object_set(X, bar, 'abc').
/* ir_object_current(X, Y, Z) */
runner_pred(ir_object_current,3, extra, update, 'XLOG 3.5.4').
runner_case(ir_object_current,3, extra, update, 'XLOG 3.5.4, XLOG 1') :-
sample_object(X), ir_object_current(X, foo, Y),
Y == 123.
runner_case(ir_object_current,3, extra, update, 'XLOG 3.5.4, XLOG 2') :-
sample_object(X), ir_object_current(X, bar, Y),
Y == 'abc'.
runner_case(ir_object_current,3, extra, update, 'XLOG 3.5.4, XLOG 3') :-
current_output(X), ir_object_current(X, 'indent', Y),
integer(Y).
runner_case(ir_object_current,3, extra, update, 'XLOG 3.5.4, XLOG 4') :-
sample_object(X), \+ ir_object_current(X, baz, _).
/* ir_object_set(X, Y, Z) */
runner_pred(ir_object_set,3, extra, update, 'XLOG 3.5.5').
runner_case(ir_object_set,3, extra, update, 'XLOG 3.5.5, XLOG 1') :-
sample_object(X), ir_object_set(X, foo, 456.0),
ir_object_current(X, foo, Y),
Y == 456.0.
runner_case(ir_object_set,3, extra, update, 'XLOG 3.5.5, XLOG 2') :-
sample_object(X), ir_object_set(X, baz, 'def'),
ir_object_current(X, baz, Y),
Y == 'def'.
/* ir_object_keys(X, Y) */
runner_pred(ir_object_keys,2, extra, update, 'XLOG 3.5.6').
runner_case(ir_object_keys,2, extra, update, 'XLOG 3.5.6, XLOG 1') :-
ir_object_new(X), ir_object_keys(X, L),
L == [].
runner_case(ir_object_keys,2, extra, update, 'XLOG 3.5.6, XLOG 2') :-
sample_object(X), ir_object_keys(X, L),
(L == [foo, bar]; L == [bar, foo]).
/****************************************************************/
/* Scalar Specials */
/****************************************************************/
/* ir_float_value(X, Y) */
runner_pred(ir_float_value,2, extra, update, 'XLOG 3.5.7').
runner_case(ir_float_value,2, extra, update, 'XLOG 3.5.7, XLOG 1') :-
ir_float_value(3.141592653589793, X), ir_float_value(Y, X),
Y == 3.141592653589793.
runner_case(ir_float_value,2, extra, update, 'XLOG 3.5.7, XLOG 2') :-
ir_float_value(1000.0, X), ir_float_value(Y, X),
Y == 1000.0.
runner_case(ir_float_value,2, extra, update, 'XLOG 3.5.7, XLOG 3') :-
catch(ir_float_value(abc,_), error(E,_), true),
E == type_error(number, abc).