Hello all. I am pretty new to prolog and understanding it so-so thus far. I have question, which seems simple, but i have not been able to come up with a solution. Its as follows:
Given a list, rotate it to the right. An example query is rotate([1,2,3], R). => R=[3,1,2]; false. There is also the constraint of only defining one predicate.
When i first read the question, i thought to myself this is simple, just get the last element of the list and move it up front. Sadly, i have not been able to do it.
Thanks for any help, and hopefully this doesn't make anyone laugh!
Given a list, rotate it to the right. An example query is rotate([1,2,3], R). => R=[3,1,2]; false. There is also the constraint of only defining one predicate.
When i first read the question, i thought to myself this is simple, just get the last element of the list and move it up front. Sadly, i have not been able to do it.
Thanks for any help, and hopefully this doesn't make anyone laugh!