swi-prolog Questions
4
Solved
I was wondering if there exists a tool that can draw a step-by-step search tree of a Prolog program? Thanks.
Sheply asked 25/2, 2012 at 21:16
3
Solved
Is there a way to just create a prolog script called hello.pl like this:
#!/usr/local/bin/swipl -q -s -t main
main:-
write('Hello World\n').
And be able to run it from the terminal like this?
...
Lifesaving asked 23/8, 2014 at 22:53
6
I am having the hardest trouble trying to run SWI-prolog on my Mac.
When I type:
/opt/bin/local/swipl
I get an error saying:
/opt/local/bin/swipl: No such file or directory
When I just type...
Sedulous asked 6/2, 2014 at 8:46
3
Solved
Can I define an anonymous predicate in SWI Prolog, bind it to a variable, and call it later? Something like this:
?- F = {(X, Y) :- Y is 2 * X}, call(F, 2.0, Y).
Semite asked 19/6, 2019 at 7:17
4
Solved
I need to count all X for which some_predicate(X) holds, and there really a lot of such X.
What is the best way to do that?
First clue is to findall, accumulate to a list and return the length of t...
Chryselephantine asked 8/5, 2011 at 21:0
4
Solved
Is there a way to force the prolog CLI to return query results with only the variables I'm interested in? A simple example would be:
?- mother(M, C1), father(F, C1).
which returns bindings for a...
Floatable asked 3/4, 2017 at 11:50
1
Solved
I could not find division (/) symbol on this page of CLP(FD): http://www.swi-prolog.org/man/clpfd.html
Also this simple code give error:
:-use_module(library(clpfd)).
afn(A,B,C):-
C #= B / A.
...
Paperboy asked 5/7, 2016 at 8:42
2
I am new to Prolog and I'm struggling with the following problem using SWI-Prolog.
I have several files dataBase1.pl, dataBase2.pl, ... with the same structure
(based on this thread)
:- module(da...
Claudette asked 10/1, 2018 at 16:27
3
Solved
Simple example:
?- between(1,10,X).
X = 1 ;
X = 2 ;
X = 3 ;
X = 4 ;
X = 5 ;
X = 6 ;
X = 7 ;
X = 8 ;
X = 9 ;
X = 10.
When this is done using SWI-Prolog using the REPL to see the next answer the s...
Rake asked 17/1, 2019 at 22:40
3
Solved
Will using member within a forall clause in SWI-Prolog always output the elements in the same order?
Having recently got into Prolog I've been using it for a few simple tasks and began to wonder about using member within forall loops like the one in the trivial example below:
forall(member(A,[1,2...
Epiphenomenalism asked 3/2, 2014 at 16:19
4
Solved
I have some .pl file and I want to call predicate declared in it from python script. How can I do that?
For example, test.pl
rD( [], Ans, Ans ).
rD( [X|Xs], Ans, Acc ) :-
member( X, Acc ),
rD( ...
Caitlyncaitrin asked 23/5, 2011 at 21:49
1
Many Prolog systems have a freeze/2 predicate, a predicate
that should possibly have the name geler/2 since it was
even invented before Prolog-II.
Assume I have a condition on the same variable, b...
Increment asked 31/1, 2016 at 22:29
1
Solved
I wrote a quick predicate in Prolog trying out CLP(FD) and its ability to solve systems of equations.
problem(A, B) :-
A-B #= 320,
A #= 21*B.
When I call it in SWI, I get:
?- problem(A,B).
32...
Sontag asked 26/12, 2017 at 6:24
1
Solved
The sample program enumerates and counts the number of 8-queen solutions. (sorry if the code is hard to read; this is machine-generated from an S-expression. The original code is https://www.cpp.ed...
Phosphate asked 10/11, 2017 at 13:13
1
Solved
I'm writing a partial-evaluator for Prolog queries. I tried to expand a query using expand_goal/2, but it simply unifies the Input with the Output in this case:
:- initialization(main).
main :-
I...
Rutile asked 6/10, 2017 at 22:5
1
Solved
I don't fully understand how SWI Prolog handles http. I have the following code which mostly works apart from the get_header/1. I need to be able to reader the header file of the http request to ge...
Aldric asked 10/6, 2017 at 18:9
5
Solved
I'm trying to convert a string to a list of ascii-codes like so:
7 ?- string_to_list("I'm a big blue banana in space!", C).
C = [73, 39, 109, 32, 97, 32, 98, 105, 103|...].
8 ?-
This doesn't g...
Likelihood asked 2/10, 2015 at 15:22
2
How Can I turn off warnings in swi-prolog.
Clauses of XXX/AA are not together in the source-file
is very annoying.
Kuvasz asked 20/3, 2010 at 5:46
1
Solved
First when I read up on different predicates on Prolog, like for example http_server, it's written like this: http_server(:Goal, +Options) what does : and + mean here? Sometimes ? is also written.
...
Shanty asked 4/12, 2016 at 19:5
4
Solved
I am trying to encode basic logical inferences in Prolog, and I want to define some custom operators to streamline the notation. It would be handy if I can type |- for ⊢. So I tried
:- op(1150, xf...
Tiphany asked 28/10, 2016 at 20:12
3
This is a question provoked by an already deleted answer to this question. The issue could be summarized as follows:
Is it possible to fold over a list, with the tail of the list generated while...
Renayrenckens asked 16/9, 2016 at 12:12
4
Solved
It seems to me one ought to be able to process binary data with DCGs on a list of bytes. To make it work generally, though, one has to use bitwise operations which means is/2 is involved, which mea...
Podophyllin asked 31/10, 2014 at 21:35
2
Solved
I am trying to implement a simple macro for switch-statements in SWI-Prolog.
This is a series of conditional statements:
(X = a ->
Output = case1;
X = b ->
Output = case2;
X = c ->
Ou...
Regeneracy asked 16/6, 2016 at 18:29
3
Solved
Update: 11.6.2016
The baffling performance discrepancy which I had observed with SICStus Prolog 4.3.2 has completely disappeared with the recently released SICStus Prolog 4.3.3. Kudos!
I updated ...
Lynn asked 11/5, 2016 at 19:5
1
Solved
Say I want to find argmax(x,y,z) -1/2(20x^2+32xy +16y^2)+2x+2y.
subject to:
x>=0, y>=0,z>=0 and -x-y+z =0.
I know the partial derivatives being set to 0 is :
-20x-16y+2=0 and -16x-16y+2 =0
so w...
Inflexed asked 10/5, 2016 at 14:52
© 2022 - 2024 — McMap. All rights reserved.