Can anyone check whether this is a complete BS of a code or not. Obviously it doesn't work because I'm getting false as answer but I just wanna know if this is on the right track or just totally NOT it. Btw I've never programmed on prolog before, I am just learning the basics.
nested([], []).
nested([H1], [[H1]])
nested([H1,H2|T], [Out]) :-
H2 - H1 is 1,
nested([H2|T], [[H1|Out]]);
nested([H2|T], [H1|Out]).
The question needs narrowing down.
I would suggest looking at Peano arithmetic, which has useful relational properties. As a simple case:
This then creates an elegant list of successors, without caring about the starting point in the first element: