Okay, I am quite new to prolog and I am trying to create a program where you have a list of numbers (representing piles of rocks) and you can take up to 4 rocks from any pile. The program needs to show all possible moves, I have it working for one pile of rocks that is any size but when I expend it I run into problems.
Is there any easier way of editing an element in a list without taking off all the elements before it.
For example if the list is [1,2,3,4,5,6] and I want to edit the 3rd item at the moment I have:
listsplit([H|T], H, T).
Which I run on the list 3 times and then when H is 3 I take off 1 and then rebuild the list. Is there any other way to do this without taking the list apart and rebuilding it?
Sorry, you need to Log In to post a reply to this thread.