Newbie without any idea!!!



Hi! The following is the requirement of the program

sum(X, 4) : X would be evaluated to 4.
sum(X, [2,4]): X would be evaluated to 6.
sum(X, [2,[2,2]]): X would be evaluated to 6.

How can I implement by Prolog?
I have the following idea.
sum(X,X).
sum(X,[H|T]):-..............

Thanks!
Ming

.