Find powers of 2 in a list Prolog

Here’s how you can find the “powers of two” in logically-pure way! Using sicstus-prolog 4.3.5, library(reif) and library(clpz): :- use_module([library(reif), library(clpz)]). power_of_two_t(I, T) :- L #= min(I,1), M #= I /\ (I-1), call((L = 1, M = 0), T). % using (=)/3 and (‘,’)/3 of library(reif) Sample query1 using meta-predicate tfilter/3 in combination with power_of_two_t/2: … Read more