swi-prolog

How to obtain the cost of each employee in Prolog?

北战南征 提交于 2020-06-29 05:04:37
问题 How would I be able to obtain the totalcost and loop through each employee to get the cost individually? Expected output: ?- make_team([batman, superman, aquaman], Heroes, TotalCost). Heroes = [[batman, bruce, wayne, 342000], [superman, clark, kent, 475000], [aquaman, arthur, curry, 5000]], TotalCost = 822000. % Returns a list of available heroes. % Each hero's information is also stored as a list. employees(E) :- E = [ [superman, clark, kent, 475000], [batman, bruce, wayne, 342000], [wonder

Nested Predicates In Prolog

送分小仙女□ 提交于 2020-06-16 17:24:34
问题 I am trying to write a predicate that ‘exists’ inside the ‘scope’ of another predicate . The reason I need this is because both predicates make use of the same very large parameters/arrays and the predicate I want to nest is doing self recurssion many times , so I want to avoid copying the same parameters . So , is there any way i can do this in Swi-Prolg ? Thanks in advance . 回答1: You don't need to. You have to realize that all the terms "named" by Prolog variable names are already global ,

true - false response of query from prolog in C#

北战南征 提交于 2020-01-25 11:22:06
问题 I am using swi- prolog with c# as front end. I want to to display whether the the query is executed or not in a mmessagebox. So i need the answer in 'true' or 'false' like it comes in prolog console. here is my code: static void Main(string[] args) { Environment.SetEnvironmentVariable("SWI_HOME_DIR", @"C:\Program Files\swipl"); Environment.SetEnvironmentVariable("PATH", @"C:\Program Files\swipl"); Environment.SetEnvironmentVariable("PATH", @"C:\Program Files\swipl\bin"); string p1 = @"C:

true - false response of query from prolog in C#

人盡茶涼 提交于 2020-01-25 11:21:08
问题 I am using swi- prolog with c# as front end. I want to to display whether the the query is executed or not in a mmessagebox. So i need the answer in 'true' or 'false' like it comes in prolog console. here is my code: static void Main(string[] args) { Environment.SetEnvironmentVariable("SWI_HOME_DIR", @"C:\Program Files\swipl"); Environment.SetEnvironmentVariable("PATH", @"C:\Program Files\swipl"); Environment.SetEnvironmentVariable("PATH", @"C:\Program Files\swipl\bin"); string p1 = @"C:

Embedding prolog engine in a dll

对着背影说爱祢 提交于 2020-01-14 13:57:29
问题 I've been working on a C++ application that embeds a prolog reasoning engine lately and, as stated in the title, I am now trying to generate a DLL instead of an executable so I can use it in another project. Since I am new to DLL development, I thought I could start with a small example. I have 3 files: likes.pl : sample prolog file defining the predicate likes/2 likes.cpp : defining the function get_food() that calls PlQuery and return the results in a std::string food.cpp : using the DLL to

How to use JPL (bidirectional Java/Prolog interface) on windows?

不羁的心 提交于 2020-01-13 10:17:14
问题 I'm interested in embedding a Prolog interpreter in Java. One option is using JPL, but the download links on the JPL site are broken, and the installation page mentions a jpl.zip that I can't find. I downloaded SWI-Prolog which seems to include JPL (it lists it as a component when installing), but I'm still not sure how I'd use it along with Java. Any ideas on how to use JPL on Windows? Is there another library I could use to achieve the same thing? I've come across a few but they don't seem

Who gave SWI-Prolog a sense of humor?

我的梦境 提交于 2020-01-07 05:05:29
问题 Who gave SWI-Prolog a sense of humor? Welcome to SWI-Prolog (threaded, 64 bits, version 7.3.35) SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software. Please run ?- license. for legal details. For online help and background, visit http://www.swi-prolog.org For built-in help, use ?- help(Topic). or ?- apropos(Word). 1 ?- Input. % ... 1,000,000 ............ 10,000,000 years later % % >> 42 << (last release gives the question) 1 ?- 回答1: Jan Wielemaker at The Beginning of Time!

how do I interact with the inferior prolog process in emacs?

吃可爱长大的小学妹 提交于 2020-01-05 07:56:27
问题 I've installed SWI-Prolog and emacs' prolog mode. I have a first_steps.pl file with prolog in it, and I do C-c C-b to consult the buffer. This opens a second buffer, prolog , whose mode is (Inferior Prolog: run). All well and good. However, it's completely unclear how to interact with that inferior prolog mode buffer. There is no prompt. Typing things and pressing return does nothing. How can I execute queries based on the code consulted from the buffer, i.e, interact with SWI-prolog? Note

Why am I getting an existence error on predsort?

安稳与你 提交于 2020-01-05 07:37:17
问题 I am trying to sort a list of paths by the distance it takes to complete them. The Prolog code I'm using is below. When I call sortRoutes , I get an existence error from Prolog saying that predsort doesn't exist. However, I am using the sort module and that doesn't seem to change anything. I can't seem to figure out why this isn't working. Am I doing anything wrong? Thanks! :- use_module(library(sort)). sortRoutes(DistRoutes, SortedRoutes) :- predsort(distCompare, DistRoutes, SortedRoutes).

Why am I getting an existence error on predsort?

泄露秘密 提交于 2020-01-05 07:35:02
问题 I am trying to sort a list of paths by the distance it takes to complete them. The Prolog code I'm using is below. When I call sortRoutes , I get an existence error from Prolog saying that predsort doesn't exist. However, I am using the sort module and that doesn't seem to change anything. I can't seem to figure out why this isn't working. Am I doing anything wrong? Thanks! :- use_module(library(sort)). sortRoutes(DistRoutes, SortedRoutes) :- predsort(distCompare, DistRoutes, SortedRoutes).