Questions tagged as 'prolog'

1
answer

Resolution with Prolog

Good afternoon, I have encountered a problem with my teacher in the Prolog class. My professor says that we can make a resolution with the following program mag(paris,mag_a). mag(paris,mag_b). mag(lyon,mag_c). mag(lyon,mag_d). liste(M):-mag...
asked by 27.04.2016 / 00:13
2
answers

Create predicate using operator: -op?

I have some doubts about the operator: -op in Prolog, because I can not handle it. My exercise is focused on creating a predicate that from a list attribute-value, whose format is [a1 => v1, a2 => v2, ..., aN => vN], get the value of a attribute...
asked by 31.08.2017 / 18:25
1
answer

Search several items in a Prolog list

I'm trying to find several items in a list: buscar([]). buscar([X|Xs]):- member(X,[a,b,c,d,e]), buscar(Xs). but just look for me if all the elements in the list are equal, true Y if an item is not the same, the query gives false but tha...
asked by 08.10.2016 / 18:07
2
answers

Prolog sublist

I want to create all the sublists of, for example, 3 elements of a list and also that these elements that it contains, before being added, fulfill a predicate. Example:    List: [11,12,9,8,7,6,5,3,2,4,15,16]   condition: & 5;   sublist: [11,...
asked by 04.07.2016 / 09:47
1
answer

Introduce new facts in prolog by asserta

I've been trying to use both asserta and assertz in my program and the compiler does not stop telling me    No permission to modify static procedure 'asserta / 1' I've been reading other messages and theoretically should be...
asked by 02.05.2018 / 23:21
2
answers

Add nodes of a tree. Prolog

Good morning, I am a beginner in Prolog and I am studying treatment of lists and trees. One question that I have is how can I add the nodes of a tree in binary principle. For example: The trees are represented as a list as follows: [[[[]...
asked by 30.05.2017 / 11:56
1
answer

Get "variables" in Swi Prolog

I have this Knowledge Base viveEn(dracula, castillo). viveEn(godzilla, espacio). viveEn(sullivan, espacio). viveEn(mLegrand, tv). maneja(godzilla, auto(4)). maneja(barney, colectivo(fucsia,10,5)). maneja(sullivan, nave([2,3,1]). And I'm doi...
asked by 24.04.2017 / 08:11
0
answers

like asking for a list in prolog

I'm trying to make a query in prolog where you specify the name of a list, which is already in the knowledge base, and tell me if a certain element is inside that list. To give an example: ?-es(green_day,rock). true. This would be the answe...
asked by 03.01.2019 / 17:35
1
answer

I need to generate a substring in the prolog language

I have a program that takes out suffixes and prefixes, but now I want to generate a sub-string and I still do not understand the prolog language. I only have this: principio:- write("Queremos saber cual es la cadena "), read(Cad),...
asked by 22.02.2018 / 23:57
0
answers

Prolog. Operations with nodes

Good morning, I would like to know how I could exchange all the nodes in a binary tree in prolog , so that If we have a tree this way: [[[[[],1,[]],5,[]], 7, [[],3,[[],4,[]]]], 6, [[[],10,[]], 8, [[[],9,[]],11,[[],2,[]]]]] I ca...
asked by 02.06.2017 / 17:15