How do i add current and previous in Prolog? Beginner prolog

calcHeu([],K) :- nl.
calcHeu([X|Rest],K) :-
findMin(X,Y),write(Y),
calcHeu(Rest,Y).

if i pass [[1,2,3],[5,4,9],[7,8,9]] it will print 1 4 7 which is minimum of each list i want to add these value and return them. in a list or as single value.

Answers


I think this is what you want. Adding Y to a list everytime.

calcHeu([],K,List) :- nl.
calcHeu([X|Rest],K,[Y|Tail]) :-
findMin(X,Y),write(Y),
calcHeu(Rest,Y,Tail).

Do you really need the K variable? Doesn't seem to do much.


Need Your Help

Call to WCF service and threads running at client & service end

silverlight-4.0 wcf

I'm sending custom header from Silverlight application to the WCF service over HTTPS. Through the custom header, I'm sending client's CultureInfo to the WCF service and expecting the response from

Method overload resolution in java

java method-overloading unboxing

Here is what I know about overload resolution in java:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.