some more fixes to make YAP swi compatible

fix absolute_file_name (again)
fix setarg


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1951 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2007-10-10 09:44:28 +00:00
parent fb37dd62ea
commit 5df974b857
13 changed files with 1630 additions and 1536 deletions

View File

@@ -30,6 +30,7 @@ PROGRAMS= $(srcdir)/apply_macros.yap \
$(srcdir)/avl.yap \
$(srcdir)/charsio.yap \
$(srcdir)/cleanup.yap \
$(srcdir)/clpfd.pl \
$(srcdir)/dbqueues.yap \
$(srcdir)/dgraphs.yap \
$(srcdir)/gensym.yap \

View File

@@ -42,6 +42,50 @@ user:file_search_path(foreign, swi(ArchLib)) :-
atom_concat('lib/', Arch, ArchLib).
user:file_search_path(foreign, swi(lib)).
:- meta_predicate prolog:predsort(:,+,-).
%% predsort(:Compare, +List, -Sorted) is det.
%
% Sorts similar to sort/2, but determines the order of two terms
% by calling Compare(-Delta, +E1, +E2). This call must unify
% Delta with one of <, > or =. If built-in predicate compare/3 is
% used, the result is the same as sort/2. See also keysort/2.
prolog:predsort(P, L, R) :-
length(L, N),
predsort(P, N, L, _, R1), !,
R = R1.
predsort(P, 2, [X1, X2|L], L, R) :- !,
call(P, Delta, X1, X2),
sort2(Delta, X1, X2, R).
predsort(_, 1, [X|L], L, [X]) :- !.
predsort(_, 0, L, L, []) :- !.
predsort(P, N, L1, L3, R) :-
N1 is N // 2,
plus(N1, N2, N),
predsort(P, N1, L1, L2, R1),
predsort(P, N2, L2, L3, R2),
predmerge(P, R1, R2, R).
sort2(<, X1, X2, [X1, X2]).
sort2(=, X1, _, [X1]).
sort2(>, X1, X2, [X2, X1]).
predmerge(_, [], R, R) :- !.
predmerge(_, R, [], R) :- !.
predmerge(P, [H1|T1], [H2|T2], Result) :-
call(P, Delta, H1, H2),
predmerge(Delta, P, H1, H2, T1, T2, Result).
predmerge(>, P, H1, H2, T1, T2, [H2|R]) :-
predmerge(P, [H1|T1], T2, R).
predmerge(=, P, H1, _, T1, T2, [H1|R]) :-
predmerge(P, T1, T2, R).
predmerge(<, P, H1, H2, T1, T2, [H1|R]) :-
predmerge(P, T1, [H2|T2], R).
%
% maybe a good idea to eventually support this in YAP.
% but for now just ignore it.
@@ -69,9 +113,7 @@ prolog:load_foreign_library(P) :-
do_volatile(_,_).
:- meta_predicate prolog:forall(+,:).
:- load_foreign_files([yap2swi], [], swi_install).
:- meta_predicate prolog:forall(:,:).
:- use_module(library(lists)).
@@ -94,6 +136,7 @@ prolog:concat_atom(List, Separator, New) :-
prolog:concat_atom(List, New) :-
atomic_concat(List, New).
split_atom_by_chars([],_,[],L,A,[]):-
atom_codes(A,L).
split_atom_by_chars([C|NewChars],C,[],L,A,[NA|Atoms]) :- !,
@@ -256,3 +299,27 @@ prolog:intersection([_|T], L, R) :-
prolog:(Term1 =@= Term2) :-
variant(Term1, Term2), !.
%% flatten(+List1, ?List2) is det.
%
% Is true it List2 is a non nested version of List1.
%
% @deprecated Ending up needing flatten/3 often indicates,
% like append/3 for appending two lists, a bad
% design. Efficient code that generates lists
% from generated small lists must use difference
% lists, often possible through grammar rules for
% optimal readability.
prolog:flatten(List, FlatList) :-
flatten(List, [], FlatList0), !,
FlatList = FlatList0.
flatten(Var, Tl, [Var|Tl]) :-
var(Var), !.
flatten([], Tl, Tl) :- !.
flatten([Hd|Tl], Tail, List) :- !,
flatten(Hd, FlatHeadTail, List),
flatten(Tl, Tail, FlatHeadTail).
flatten(NonList, Tl, [NonList|Tl]).

File diff suppressed because it is too large Load Diff