The task

Three neighbouring elements of an integer list form a sum triplet or a difference triplet, respectively, if the sum or the difference, respectively, of the first and the third elements of the triplet equals to the middle element of the triplet.

Write an SML function called sumdiff that returns true if and only if the list passed in its argument contains at least one sum triplet or difference triplet.

(* sumdiff : int list -> bool
   sumdiff zs = true iff zs contains at least one sum or difference triplet
*)
Write declarative head comments to any auxiliary function you wish to define.

Examples:

sumdiff [] = false;
sumdiff [1,1] = false;
sumdiff [1,2,4] = false;
sumdiff [1,2,~1] = true;
sumdiff [1,2,3,~1] = true;
sumdiff [1,2,3,~1,2] = true;
sumdiff [1,2,4,~3,4] = false;