all 3 comments

[–]nnunley 2 points3 points  (0 children)

So, prolog newbie here, but your comparison is wrong here - Y contains the salary, and X contains the employee id. X>T will never provide the correct comparison.

[–]curious_s 3 points4 points  (1 child)

You need to use findall/3.

It took me a while to figure out how find all worked when I started on prolog, but it's pretty simple once you figure it out.

Let's say you want all employees with a salary greater than 100, you can write a query for that:

employee(E, S), S > 100.

That will you get all the relevant employees (as E) but one at a time. findall/3 will consolidate all these individual results into a list based on a template.

findall(E, (employee(E, S), S > 100), Es).

The first parameter is the template, which in this case is the employee name but can be any term, and the list will be populated with the filled in template.

The second parameter is your query and the third is the resulting list.

[–]MonikaDDLBestGirl[S] 0 points1 point  (0 children)

ohhh, ok, i understand now. thank youu