I want to add any strings user entered into a list
run :- write('How many students you have: '),read(x),nl.
enterNameOfStudents(x).
enterNameOfStudents(x) :- for(A, 1, x, 1),write('Please enter the names of students'),read(A),??????,nl,fail.
What do i put in the ?????? portion to ensure that whatever the user enter will go int...
How do i read in char type by users if they are a- , b+ , o+ ? I don't seem to have problem reading in char like a , b , c or d. i am using read(X) . Can someone help me out with this ? Thanks in advance.
...
In my prolog rule
marriedcouple(X,Y) :-
parent((X,Z),bornin(_)),
parent((Y,Z),bornin(_)),
female(X),male(Y);
male(X),female(Y),
different(X,Y).
when a parent has two kids, the couple shows twice. How can we prevent this ?
...
I get several results with the same outputs.
I want to get jack,jane only one time, but I get it two times.
How can I avoid this? I tried setof but I couldn't get it done. Please can someone help me on this?
...
I have this problem containing some inequations and requirement to minimize a value. After doing some research on the Internet, I came to conclusion that using Prolog might be the easiest way to solve it. However, I never used Prolog before, and I would hate to waste my time learning it just to discover that it is not the right tool for ...
How Can I turn off warnings in swi-prolog.
Clauses of XXX/AA are not together in the source-file
is very annoying.
...
Hello SO,
I have a very weird problem with PROLOG. I have used it before, but it's been a while and I'm rusty. I have a list of variables and I need to ensure that none of them are the same.
I have tried:
use_module(library(bounds)).
all_different(A, B, C, D, 6, 8).
However, when I try this, I get an error saying that all_different...
A new web application may require adding Artificial Intelligence (AI) in the future, e.g. using ProLog. I know it can be done from a Java environment, but I am wondering about the opportunities with modern web languages like Ruby or Python. The latter is considered to be "more scientific" (at least used in that environment), but using Go...
Hello SO,
I am writing a PROLOG program in which the variable of interest (Q) refuses to unify. I have gotten around this with a hacky solution (include a write statement). But there has to be a way to make this unify, but for the love of me, I am not able to figure it out.
I'd really appreciate any help.
Thanks in advance.
Here is my...
I am new to learning prolog, and I want to know, if we have some procedure like
father("Nic","Adam").
and I want to write a function that it will add new value to this
father("Nic","Adam","something"..)
how can I do this? Using list? Or what?
...
What I need to do is to break atom to tokens. E. g.:
tokenize_string('Hello, World!', L).
would unify L=['Hello',',','World','!']. Exactly as tokenize_atom/2 do. But when I try to use tokenize_atom/2 with non-latin letters it fails. Is there any universal replacement or how I can write one? Thanks in advance.
...
Lets say that I would like to construct a list (L2) by appending elements of another list (L) one by one. The result should be exactly the same as the input.
This task is silly, but it'll help me understand how to recurse through a list and remove certain elements.
I have put together the following code:
create(L, L2) :- (\+ (L == []) ...
I am new to prolog and I'm trying to to create function that will simply remove all instances of an element from a list. The following code is what I have so far:
remove([H|T], E, L2) :- (\+ ([H|T] == []) ->
(H == E
-> remove(T, E, L2)
; append(L2, H, L2), remove(T, E, L2)
)
; append(L2, [])
).
When I run ...
hey guys i have a question regarding amzi prolog with eclipse,
Im running a .pro file which executes a breadth first search and if queue gets too long,
the following error message appears:
system_error 1021 Control stack full.
Compile code or increase .cfg
parameter 'control'
If so, how may i run the compiled code under eclip...
The following predicate is remove(L, X, R), where L is a list, X is an element to remove from the list. The code returns the correct list, however it always also returns false afterwards.
I can't find the place where two of the rules can be applied during runtime.
remove([],X,[]) :- !.
remove([X|T],X,L1) :- remove(T,X,L1).
remove([H...
Hi , I have a problem in my code with turbo prolog wich search all paths and the shortest path for a graph between 2 nodes
the problem that i have is to test if the node is on the list or not exactly in the clause of member
and this is my code :
/*
1 ---- b ---- 3
--- | ---
--- ...
I have three types of facts:
album(code, artist, title, date).
songs(code, songlist).
musicians(code, list).
Example:
album(123, 'Rolling Stones', 'Beggars Banquet', 1968).
songs(123, ['Sympathy for the Devil', 'Street Fighting Man']).
musicians(123, [[vocals, 'Mick Jagger'], [guitar, 'Keith Richards', 'Brian Jones']].
I need t...
It would be a great help on my course.
...
I am attempting to locate the nth element of a List in Prolog. Here is the code I am attempting to use:
Cells = [OK, _, _, _, _, _] .
...
next_safe(_) :-
facing(CurrentDirection),
delta(CurrentDirection, Delta),
in_cell(OldLoc),
NewLoc is OldLoc + Delta,
nth1(NewLoc, Cells, SafetyIdentifier),
SafetyIdentifier = OK .
Basically, I a...
Basically I am attempting to have an AI agent navigate a world based on given percepts. My issue is handling how the agent moves. Basically, I have created find_action/4 such that we pass in the percepts, action, current cell, and the direction the agent is facing. As it stands the entire code looks like: http://wesnoth.pastebin.com/kdNv...