1:- module(canny_pop,
    2          [ pop_lsbs/2                           % +A:nonneg,-L:list
    3          ]).
 pop_lsbs(+A:nonneg, -L:list) is det
Unifies non-negative integer A with its set bits L in least-significate priority order. Defined only for non-negative A. Throws a domain error otherwise.
Errors
- domain_error(not_less_than_one, A) if A less than 0.
   13pop_lsbs(0, []) :- !.
   14pop_lsbs(A, [H|T]) :-
   15    H is lsb(A),
   16    B is A /\ \(1 << H),
   17    pop_lsbs(B, T)