How to define (and name) the corresponding safe term comparison predicates in ISO Prolog?

iso_dif/2 is much simpler to implement than a comparison: The built-in \= operator is available You now exactly what arguments to provide to\= Definition Based on your comments, the safe comparison means that the order won’t change if variables in both subterms are instanciated. If we name the comparison lt, we have for example: lt(a(X), … Read more

Unification with STO detection

Third attempt. This is mainly a bugfix in a previous answer (which already had many modifications). Edit: 06/04/2015 When creating a more general term I was leaving both subterms as-is if either of them was a variable. Now I build a more general term for the “other” subterm in this case, by calling term_general/2. unify_sto(X,Y):- … Read more

Rearranging variable_names

avs_term_rearranged(AVs, T, AVsR) :- term_variables(T, Vs), copy_term(Vs+AVs, Vs1+AVs1), bind_names(AVs1), build_vn_list(Vs, Vs1, AVsR). bind_names([]). bind_names([N=V|AVs]) :- N = V, bind_names(AVs). build_vn_list([], [], []). build_vn_list([V|Vs],[N|Ns],NVs) :- ( atom(N) -> NVs = [N=V|NVs1] ; var(N) -> NVs = NVs1 ), build_vn_list(Vs, Ns, NVs1).

‘if’ in prolog?

Yes, there is such a control construct in ISO Prolog, called ->. You use it like this: ( condition -> then_clause ; else_clause ) Here is an example that uses a chain of else-if-clauses: ( X < 0 -> writeln(‘X is negative. That’s weird! Failing now.’), fail ; X =:= 0 -> writeln(‘X is zero.’) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)