[(Unsuccessful) messing with backtracking, another test case for split. gergo@complang.tuwien.ac.at**20090126102518] { hunk ./qsort-example.fs 28 + \ ." split clause 1" cr hunk ./qsort-example.fs 33 + \ prolog-success @ if ." matched fact 1" cr endif hunk ./qsort-example.fs 42 + \ ." split clause 2" cr hunk ./qsort-example.fs 49 + \ prolog-success @ if ." matched head 2" cr endif hunk ./qsort-example.fs 61 + \ ." split clause 3" cr hunk ./qsort-example.fs 71 + \ prolog-success @ if ." matched head 3" cr endif hunk ./qsort-example.fs 90 + \ ." split clause 4" cr hunk ./qsort-example.fs 100 + \ prolog-success @ if ." matched head 4" cr else + \ ." failing goal: split(" + \ a1 @ unparse ." , " + \ a2 @ unparse ." , " + \ a3 @ unparse ." , " + \ a4 @ unparse ." )" cr + \ endif hunk ./qsort-example.fs 130 +4 create-integer create four , +5 create-integer create five , hunk ./qsort-example.fs 173 + +." :- split(Xs, 3, [1,2], [4,5])" cr +create-unbound create xs , +:noname + ." Xs = " xs @ unparse cr + ; is print-solutions +one @ two @ create-nil create-list create-list create lowers , +four @ five @ create-nil create-list create-list create uppers , +xs @ a1 ! +pivot-three @ a2 ! +lowers @ a3 ! +uppers @ a4 ! +' split prolog-shell cr hunk ./wam.fs 640 + \ FIXME: Alternative solutions for split(Xs, 3, [1,2], [4,5]) are not + \ found using this code. hunk ./wam.fs 648 - pop-choice-point + global-state cp-b @ stack > if + pop-choice-point + endif hunk ./wam.fs 653 - alternative pl-call + global-state cp-bp @ pl-call hunk ./wam.fs 655 - alternative pl-execute + global-state cp-bp @ pl-execute hunk ./wam.fs 659 + global-state cp-b @ stack > if + \ ." cp-b @ = " global-state cp-b @ . + \ ." , stack = " stack . + \ ." , trying to pop choice point to retry" cr + pop-choice-point + \ -1 prolog-success ! + recurse + endif hunk ./wam.fs 671 +:noname ( flag -- ) + begin + \ Find a choice point with a non-fail alternative, if any. + fail global-state cp-bp @ = + global-state cp-b @ stack > and while + pop-choice-point + repeat + global-state cp-bp @ { alternative } + fail alternative <> if + \ Found one, retry. + -1 prolog-success ! + ( flag ) + 0= if + alternative pl-call + else + alternative pl-execute + endif + endif + ; \ is try-alternatives + hunk ./wam.fs 875 + \ ." global-s = " global-s . cr + \ ." global-s @ = " global-s @ . cr + \ ." global-s @ @ = " global-s @ @ . cr + \ ." global-s @ @ @ = " global-s @ @ @ . cr + \ ." global-s @ @ = " global-s @ @ unparse cr }