Please help me to solve this problem:
subset(N, [1,2,3], L).
if N=2, I want the result is that:
[1,2];
[2,1];
[1,3];
[3,1];
[2,3];
[3,2];
(in any order)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, your base case is trivial:
If N>0, you have 2 choices as to what to do with the first element of Lst:
You might think you have to worry about Lst being too short (or N being too big: same thing), but if you’ve coded the above properly, it should be taken care of for you.
Hoep that’s enough to get you started.