Prolog "struc"

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, struc, 'XLOG 3.4 atoms').
/****************************************************************/
/* atom.p extras */
/****************************************************************/
/* last_sub_atom(X, Y, Z, T, U) */
/* derived from sub_atom/5 test cases. */
runner_pred(last_sub_atom, 5, extra, struc, 'XLOG 3.4.2').
runner_case(last_sub_atom, 5, extra, struc, 'XLOG 3.4.2, XLOG 1') :-
last_sub_atom(abracadabra, 0, 5, _, S),
S == abrac.
runner_case(last_sub_atom, 5, extra, struc, 'XLOG 3.4.2, XLOG 2') :-
last_sub_atom(abracadabra, _, 5, 0, S),
S == dabra.
runner_case(last_sub_atom, 5, extra, struc, 'XLOG 3.4.2, XLOG 3') :-
last_sub_atom(abracadabra, 3, L, 3, S),
L == 5, S == acada.
runner_case(last_sub_atom, 5, extra, struc, 'XLOG 3.4.2, XLOG 4a') :-
last_sub_atom(abracadabra, B, 2, A, ab), !,
B == 7, A == 2.
runner_case(last_sub_atom, 5, extra, struc, 'XLOG 3.4.2, XLOG 4b') :-
findall(A-B,last_sub_atom(abracadabra, B, 2, A, ab),[_,A-B|_]),
B == 0, A == 9.
runner_case(last_sub_atom, 5, extra, struc, 'XLOG 3.4.2, XLOG 5') :-
last_sub_atom('Banana', 3, 2, _, S),
S == 'an'.
runner_case(last_sub_atom, 5, extra, struc, 'XLOG 3.4.2, XLOG 6a') :-
last_sub_atom(charity, _, 3, _, S), !,
S == 'ity'.
runner_case(last_sub_atom, 5, extra, struc, 'XLOG 3.4.2, XLOG 6b') :-
findall(S,last_sub_atom(charity, _, 3, _, S),[_,S|_]),
S == 'rit'.
runner_case(last_sub_atom, 5, extra, struc, 'XLOG 3.4.2, XLOG 7a') :-
last_sub_atom(ab, Start, Length, _, Sub_atom), !,
Start == 2, Length == 0, Sub_atom == ''.
runner_case(last_sub_atom, 5, extra, struc, 'XLOG 3.4.2, XLOG 7b') :-
findall(Start-Length-Sub_atom, last_sub_atom(ab, Start, Length, _, Sub_atom),
[_,Start-Length-Sub_atom|_]),
Start == 1, Length == 1, Sub_atom == 'b'.
/* atom_join(X, Y) */
runner_pred(atom_join, 2, extra, struc, 'XLOG 3.4.3').
runner_case(atom_join, 2, extra, struc, 'XLOG 3.4.3, XLOG 1') :-
atom_join([foo,bar], X),
X == 'foobar'.
runner_case(atom_join, 2, extra, struc, 'XLOG 3.4.3, XLOG 2') :-
\+ atom_join([bar,baz], 'foobar').
runner_case(atom_join, 2, extra, struc, 'XLOG 3.4.3, XLOG 3') :-
catch(atom_join(foo, _), error(E,_), true),
E == type_error(list,foo).
/****************************************************************/
/* atom.p extras II */
/****************************************************************/
/* atom_number(X, Y) */
runner_pred(atom_number, 2, extra, struc, 'XLOG 3.4.4').
runner_case(atom_number, 2, extra, struc, 'XLOG 3.4.4, XLOG 1') :-
atom_number(X, 33), X == '33'.
runner_case(atom_number, 2, extra, struc, 'XLOG 3.4.4, XLOG 2') :-
atom_number('33.0', X), X == 33.0.
runner_case(atom_number, 2, extra, struc, 'XLOG 3.4.4, XLOG 3') :-
atom_number('3.3e+01', 33.0).
runner_case(atom_number, 2, extra, struc, 'XLOG 3.4.4, XLOG 4') :-
X is 23/10,
atom_number(Y, X), Y == '2.3'.
runner_case(atom_number, 2, extra, struc, 'XLOG 3.4.4, XLOG 5') :-
X is 3.703703670370371e29 / 1.2345678901234568e29,
atom_number(Y, X), Y == '3.0000000000000004'.
runner_case(atom_number, 2, extra, struc, 'XLOG 3.4.4, XLOG 6') :-
X is 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1,
atom_number(Y, X), Y == '0.7999999999999999'.
runner_case(atom_number, 2, extra, struc, 'XLOG 3.4.4, XLOG 7') :-
X is 10000000000000000.0,
atom_number(Y, X), Y == '1.0e16'.
runner_case(atom_number, 2, extra, struc, 'XLOG 3.4.4, XLOG 8') :-
catch(atom_number('0xf', _), error(E,_), true),
E == syntax_error(illegal_number).
runner_case(atom_number, 2, extra, struc, 'XLOG 3.4.4, XLOG 9') :-
catch(atom_number(_, foo), error(E,_), true),
E == type_error(number,foo).
runner_case(atom_number, 2, extra, struc, 'XLOG 3.4.4, XLOG 10') :-
catch(atom_number(_, _), error(E,_), true),
E == instantiation_error.