Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Prolog - Recursion loop ends suddenly / Query to display lowest value first.

Hey guys.

I apologize for the lack of information I'm going to write in this post (it's an assignment and I'm paranoid that my full code will be linked back to me.

Essentially what my .pl is doing is reading from a .data file and it then parses the information and applys simple text modification to make it prolog standard (i.e capital letters are changed to lower case) and then it adds it as a rule using a function similar to this fridge(X, D, A, S).

I know that the recursion works correctly as intended as it goes through the entire file and prints out the information but when I attempt to use the function fridge(X, D, A, S) and add that particular fridge, the program stops after the first attempt to add that particular fridge in the database.

Here's a section of the code that attempts to add the fridge if that shows a little more light on whats happening:

Code
add_fridge([Model, Serial, Litre, Weight]) :-
    write(Model),
    write(Serial),
    write(Litre),
    write(Weight),
    fridge(Model, Serial, Litre, Weight).

It'll attempt to add the fridge, but when checking if it's in the database it'll return false and not return the entire contents of the file like it usually does when the fridge() command is commented out.

I hope that you're able to understand what I mean.
[/code]
I've also got to produce a query that returns the lowest litre fridge first, google wasn't able to help me (atleast with the top 3 searches anyway and the rest were unrelated).

Cheers guys, posts or PMs are appreciated.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by h40xerApr 22, 2026 04:27 PM 0 57 Apr 22, 2026 04:27 PM
Last Post: h40xer
by paradox_Mar 1, 2017 11:19 PM 2 148 Mar 1, 2017 11:19 PM
Last Post: severos
[Tutorial] by ElmagoLokoFeb 28, 2017 04:39 AM 3 170 Feb 28, 2017 04:39 AM
Last Post: kane2026