I have a list that I create as follows:
tab([(top,left),(top,middle),(top,right),(center,left),(center,middle),
(center,right),(bottom,left),(bottom,middle),(bottom,right)]).
I wish to create a global variable AllPosition that is a tab. So I did the following:
tab(AllPos).
Is this right?
Then I have to follow problem: I have a function that receives one of the pair in tab. That I wish to remove. So I did this:
place(Line, Column, Tab) :-
AllPos \== [_,_] /*while AllPos isn't empty - not sur if this is done this way*/ -> (member((Line,Column), AllPos) -> (erase(AllPos, (Line,Column), AllPos)).
where erase(List, Element, NewList)
erases the element Element from List and creates a new list NewList equal to List but without Element. Both functions member
and erase
are working.
The thing is... As you might have noticed I use AllPos
everywhere. That's because I want to, I want to modify it so I can use it later (after having removed some elements from it), in another function. Is my logic right? Will I be able to use modified AllPos in another function?
Thanks