Are they elements of the list just decimal digits? Prolog has a built-in length/2 predicate for doing a list length. The other issue is the recursion is a little bit the wrong direction in your current design: you want to do number(XS, L) then Y is L+YY.
–
lurkerMay 22 '14 at 20:25