Prolog - Get a specifc part of a Term











up vote
-1
down vote

favorite












I have a compound/Term, I'm a not sure how to treat it really, which looks like this, and is a result of a findall term -



    findall((Board,P1->P2,Player),is_move_legal(Board,P1,P2,_,Player),Moves),


which results in the following term -



(   game_board(l(0, b, 0, b, 0, b, 0, b),

l(b, 0, b, 0, b, 0, b, 0),

l(0, b, 0, b, 0, b, 0, b),

l(1, 0, 1, 0, 1, 0, 1, 0),

l(0, 1, 0, 1, 0, 1, 0, 1),

l(w, 0, w, 0, w, 0, w, 0),

l(0, w, 0, w, 0, w, 0, w),

l(w, 0, w, 0, w, 0, w, 0)),

p(3, 8)-> p(4, 7),

b

).


This is a Checkers Board, with rows, and the selected move is p(3,8) to p(4,7). The point is, the move isn't really made in my board, and I want the fetch only the phrase p(3, 8)-> p(4, 7). I want to be able to isolate p(3,8) and p(4,7) in my code, so I can make the move.



This term is splitted into "parts", as
What is the best way of doing it?



Thank you










share|improve this question
























  • You need to read How to Ask and then provide us with a Minimal, Complete, and Verifiable example. If you have any questions about these two pages please ask here in the comments.
    – Enigmativity
    Nov 12 at 8:29










  • @Enigmativity thank you for your answer. I don't think I can get my code to work on somebody else's machine, since he'd have to copy-paste my whole 100 line "Board" code. Isn't it possible to answer the question with the data I've provided?
    – Alan
    Nov 12 at 8:31










  • most likely, findall(P1->P2,is_move_legal(Board,P1,P2,_,Player),Moves),
    – CapelliC
    Nov 12 at 9:36






  • 1




    @Alan - Copying and pasting 100 lines of code is perfectly fine, so long as it is a Minimal, Complete, and Verifiable example.
    – Enigmativity
    Nov 12 at 10:22










  • @CapelliC thank you, but how do I fetch P1,P2, after I made the "findall" predicate? I have it in a long variable, and I wan't to fetch just part of it.
    – Alan
    Nov 12 at 10:42















up vote
-1
down vote

favorite












I have a compound/Term, I'm a not sure how to treat it really, which looks like this, and is a result of a findall term -



    findall((Board,P1->P2,Player),is_move_legal(Board,P1,P2,_,Player),Moves),


which results in the following term -



(   game_board(l(0, b, 0, b, 0, b, 0, b),

l(b, 0, b, 0, b, 0, b, 0),

l(0, b, 0, b, 0, b, 0, b),

l(1, 0, 1, 0, 1, 0, 1, 0),

l(0, 1, 0, 1, 0, 1, 0, 1),

l(w, 0, w, 0, w, 0, w, 0),

l(0, w, 0, w, 0, w, 0, w),

l(w, 0, w, 0, w, 0, w, 0)),

p(3, 8)-> p(4, 7),

b

).


This is a Checkers Board, with rows, and the selected move is p(3,8) to p(4,7). The point is, the move isn't really made in my board, and I want the fetch only the phrase p(3, 8)-> p(4, 7). I want to be able to isolate p(3,8) and p(4,7) in my code, so I can make the move.



This term is splitted into "parts", as
What is the best way of doing it?



Thank you










share|improve this question
























  • You need to read How to Ask and then provide us with a Minimal, Complete, and Verifiable example. If you have any questions about these two pages please ask here in the comments.
    – Enigmativity
    Nov 12 at 8:29










  • @Enigmativity thank you for your answer. I don't think I can get my code to work on somebody else's machine, since he'd have to copy-paste my whole 100 line "Board" code. Isn't it possible to answer the question with the data I've provided?
    – Alan
    Nov 12 at 8:31










  • most likely, findall(P1->P2,is_move_legal(Board,P1,P2,_,Player),Moves),
    – CapelliC
    Nov 12 at 9:36






  • 1




    @Alan - Copying and pasting 100 lines of code is perfectly fine, so long as it is a Minimal, Complete, and Verifiable example.
    – Enigmativity
    Nov 12 at 10:22










  • @CapelliC thank you, but how do I fetch P1,P2, after I made the "findall" predicate? I have it in a long variable, and I wan't to fetch just part of it.
    – Alan
    Nov 12 at 10:42













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a compound/Term, I'm a not sure how to treat it really, which looks like this, and is a result of a findall term -



    findall((Board,P1->P2,Player),is_move_legal(Board,P1,P2,_,Player),Moves),


which results in the following term -



(   game_board(l(0, b, 0, b, 0, b, 0, b),

l(b, 0, b, 0, b, 0, b, 0),

l(0, b, 0, b, 0, b, 0, b),

l(1, 0, 1, 0, 1, 0, 1, 0),

l(0, 1, 0, 1, 0, 1, 0, 1),

l(w, 0, w, 0, w, 0, w, 0),

l(0, w, 0, w, 0, w, 0, w),

l(w, 0, w, 0, w, 0, w, 0)),

p(3, 8)-> p(4, 7),

b

).


This is a Checkers Board, with rows, and the selected move is p(3,8) to p(4,7). The point is, the move isn't really made in my board, and I want the fetch only the phrase p(3, 8)-> p(4, 7). I want to be able to isolate p(3,8) and p(4,7) in my code, so I can make the move.



This term is splitted into "parts", as
What is the best way of doing it?



Thank you










share|improve this question















I have a compound/Term, I'm a not sure how to treat it really, which looks like this, and is a result of a findall term -



    findall((Board,P1->P2,Player),is_move_legal(Board,P1,P2,_,Player),Moves),


which results in the following term -



(   game_board(l(0, b, 0, b, 0, b, 0, b),

l(b, 0, b, 0, b, 0, b, 0),

l(0, b, 0, b, 0, b, 0, b),

l(1, 0, 1, 0, 1, 0, 1, 0),

l(0, 1, 0, 1, 0, 1, 0, 1),

l(w, 0, w, 0, w, 0, w, 0),

l(0, w, 0, w, 0, w, 0, w),

l(w, 0, w, 0, w, 0, w, 0)),

p(3, 8)-> p(4, 7),

b

).


This is a Checkers Board, with rows, and the selected move is p(3,8) to p(4,7). The point is, the move isn't really made in my board, and I want the fetch only the phrase p(3, 8)-> p(4, 7). I want to be able to isolate p(3,8) and p(4,7) in my code, so I can make the move.



This term is splitted into "parts", as
What is the best way of doing it?



Thank you







prolog






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 0:21









false

11.1k770142




11.1k770142










asked Nov 12 at 8:13









Alan

5192620




5192620












  • You need to read How to Ask and then provide us with a Minimal, Complete, and Verifiable example. If you have any questions about these two pages please ask here in the comments.
    – Enigmativity
    Nov 12 at 8:29










  • @Enigmativity thank you for your answer. I don't think I can get my code to work on somebody else's machine, since he'd have to copy-paste my whole 100 line "Board" code. Isn't it possible to answer the question with the data I've provided?
    – Alan
    Nov 12 at 8:31










  • most likely, findall(P1->P2,is_move_legal(Board,P1,P2,_,Player),Moves),
    – CapelliC
    Nov 12 at 9:36






  • 1




    @Alan - Copying and pasting 100 lines of code is perfectly fine, so long as it is a Minimal, Complete, and Verifiable example.
    – Enigmativity
    Nov 12 at 10:22










  • @CapelliC thank you, but how do I fetch P1,P2, after I made the "findall" predicate? I have it in a long variable, and I wan't to fetch just part of it.
    – Alan
    Nov 12 at 10:42


















  • You need to read How to Ask and then provide us with a Minimal, Complete, and Verifiable example. If you have any questions about these two pages please ask here in the comments.
    – Enigmativity
    Nov 12 at 8:29










  • @Enigmativity thank you for your answer. I don't think I can get my code to work on somebody else's machine, since he'd have to copy-paste my whole 100 line "Board" code. Isn't it possible to answer the question with the data I've provided?
    – Alan
    Nov 12 at 8:31










  • most likely, findall(P1->P2,is_move_legal(Board,P1,P2,_,Player),Moves),
    – CapelliC
    Nov 12 at 9:36






  • 1




    @Alan - Copying and pasting 100 lines of code is perfectly fine, so long as it is a Minimal, Complete, and Verifiable example.
    – Enigmativity
    Nov 12 at 10:22










  • @CapelliC thank you, but how do I fetch P1,P2, after I made the "findall" predicate? I have it in a long variable, and I wan't to fetch just part of it.
    – Alan
    Nov 12 at 10:42
















You need to read How to Ask and then provide us with a Minimal, Complete, and Verifiable example. If you have any questions about these two pages please ask here in the comments.
– Enigmativity
Nov 12 at 8:29




You need to read How to Ask and then provide us with a Minimal, Complete, and Verifiable example. If you have any questions about these two pages please ask here in the comments.
– Enigmativity
Nov 12 at 8:29












@Enigmativity thank you for your answer. I don't think I can get my code to work on somebody else's machine, since he'd have to copy-paste my whole 100 line "Board" code. Isn't it possible to answer the question with the data I've provided?
– Alan
Nov 12 at 8:31




@Enigmativity thank you for your answer. I don't think I can get my code to work on somebody else's machine, since he'd have to copy-paste my whole 100 line "Board" code. Isn't it possible to answer the question with the data I've provided?
– Alan
Nov 12 at 8:31












most likely, findall(P1->P2,is_move_legal(Board,P1,P2,_,Player),Moves),
– CapelliC
Nov 12 at 9:36




most likely, findall(P1->P2,is_move_legal(Board,P1,P2,_,Player),Moves),
– CapelliC
Nov 12 at 9:36




1




1




@Alan - Copying and pasting 100 lines of code is perfectly fine, so long as it is a Minimal, Complete, and Verifiable example.
– Enigmativity
Nov 12 at 10:22




@Alan - Copying and pasting 100 lines of code is perfectly fine, so long as it is a Minimal, Complete, and Verifiable example.
– Enigmativity
Nov 12 at 10:22












@CapelliC thank you, but how do I fetch P1,P2, after I made the "findall" predicate? I have it in a long variable, and I wan't to fetch just part of it.
– Alan
Nov 12 at 10:42




@CapelliC thank you, but how do I fetch P1,P2, after I made the "findall" predicate? I have it in a long variable, and I wan't to fetch just part of it.
– Alan
Nov 12 at 10:42

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258108%2fprolog-get-a-specifc-part-of-a-term%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258108%2fprolog-get-a-specifc-part-of-a-term%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)