Can someone please guide me or explain how to perform backtracking in LISP ? Any examples or links would be appreciated.
I did try to google , however none of them had simple example enough for me to understand.
Thanks
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.
The typical way is to have non-mutable state passed down the call-stack, with helper functions taking the current state-returning a new state to “fake” mutation.
A possible (although rather suboptimal) sudoku-solver would then be:
This will automatically backtrack until a solution is found. I have skipped obscuring the demonstration with the support code that would turn it from a demonstration to actual working code.