To find the sum of given list in PROLOG Earthcare Foundation NGO 22:22 Prolog No comments list_sum([],0). list_sum([H|T],Total):-list_sum(T,Sum1),Total is H+Sum1. Output 1 ?- list_sum([1,2,34,4],Sum). Sum = 41. 2 ?- list_sum([1,2,34,4,3,6,7,8],Sum). Sum = 65. Share This: Facebook Twitter Google+ Stumble Digg Email ThisBlogThis!Share to XShare to Facebook
0 comments:
Post a Comment