/usr/share/Yap/pl/arrays.yap is in yap 6.2.2-6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: arrays.yap *
* Last rev: *
* mods: *
* comments: Array Manipulation *
* *
*************************************************************************/
%
% These are the array built-in predicates. They will only work if
% YAP_ARRAYS is defined in Yap.h.m4.
%
array(Obj, Size) :-
'$create_array'(Obj, Size).
% arithmetical optimization
'$c_arrays'((P:-Q),(NP:-QF)) :- !,
'$c_arrays_body'(Q, QI),
'$c_arrays_head'(P, NP, QI, QF).
'$c_arrays'(P, NP) :-
'$c_arrays_fact'(P, NP).
'$c_arrays_body'(P, P) :-
var(P), !.
'$c_arrays_body'((P0,Q0), (P,Q)) :- !,
'$c_arrays_body'(P0, P),
'$c_arrays_body'(Q0, Q).
'$c_arrays_body'((P0;Q0), (P;Q)) :- !,
'$c_arrays_body'(P0, P),
'$c_arrays_body'(Q0, Q).
'$c_arrays_body'((P0->Q0), (P->Q)) :- !,
'$c_arrays_body'(P0, P),
'$c_arrays_body'(Q0, Q).
'$c_arrays_body'(P, NP) :- '$c_arrays_lit'(P, NP).
%
% replace references to arrays to references to built-ins.
%
'$c_arrays_lit'(G, GL) :-
'$array_references'(G, NG, VL),
'$add_array_entries'(VL, NG, GL).
'$c_arrays_head'(G, NG, B, NB) :-
'$array_references'(G, NG, VL),
'$add_array_entries'(VL, B, NB).
'$c_arrays_fact'(G, NG) :-
'$array_references'(G, IG, VL),
(VL = [] -> NG = G;
NG = (IG :- NB), '$add_array_entries'(VL, true, NB)).
'$add_array_entries'([], NG, NG).
'$add_array_entries'([Head|Tail], G, (Head, NG)) :-
'$add_array_entries'(Tail, G, NG).
static_array_properties(Name, Size, Type) :-
atom(Name), !,
'$static_array_properties'(Name, Size, Type).
static_array_properties(Name, Size, Type) :-
var(Name), !,
current_atom(Name),
'$static_array_properties'(Name, Size, Type).
static_array_properties(Name, Size, Type) :-
'$do_error'(type_error(atom,Name),static_array_properties(Name,Size,Type)).
|