Portability is one of most weak points of Prolog - the ISO standard defines current_prolog_flag/2, but not lists among flags the 'name' of implementation.
I used the following code to switch among SWI and YAP
swi :- prolog_impl(swi).
yap :- prolog_impl(yap).
prolog_impl(K) :-
F =.. [K,_,_,_,_],
current_prolog_flag(version_data, F).
and then used it like
:- if(swi).
gen_hash_lin_probe(Key, HashTable, Value) :-
arg(_, HashTable, E),
nonvar(E),
E = Key-Value.
:- elif(yap).
gen_hash_lin_probe(Key, HashTable, Value) :-
HashTable =.. [htlp|Args],
nth1(_, Args, E),
nonvar(E),
E = Key-Value.
:- endif.
but GNU doesn't define version_data
. Then that code should be extended more or less like
...
catch(current_prolog_flag(version_data,F),_,K = gnu).
(note: not tested)
To test existence of a builtin there is predicate_property/2 (AFAIK not ISO) and you will need to experiment - as usual - the determine the actual behaviour.
OT: sumlist/2 is deprecated, there is sum_list/2