Given a List of numbers in Prolog, how can you divide it intosub_lists?
Every time there is a change in integer sign, you start anothersub list.
Eg -sign_runs([8,-3,-9,1,5,-2], Result)
Result = [[8],[-3,-9], [1,5], [-2]]
My attempt:
pack([],[]).
pack([X|Xs],[Z|Zs]) :-transfer(X,Xs,Ys,Z), pack(Ys,Zs).
transfer(X,[],[],[X]).
transfer(X,[Y|Ys],[Y|Ys],[X]) :-
diff(X, Y, Ans),
Ans =:= 1.
transfer(X,[X|Xs],Ys,[X|Zs]) :- transfer(X,Xs,Ys,Zs).
diff(N1, N2, 0) :-
sign(N1, A),
sign(N2, B),
A =:= B.
diff(N1, N2, 1) :-
sign(N1, A),
sign(N2, B),
A == B.
sign(Num, 1) :-
Num > 0.
sign(Num, 0) :-
Num < 0.
But prolog returnsFalse and not the Answer to Result.
Expert Answer
An answer
PayPal Gateway not configured
PayPal Gateway not configured