Goal expansion for an `if_/3` operator in Prolog
问题 I'm writing a tokeniser and I want to use if_/3 to preserve logical-purity in my code. The code looks like the following code 1 on the left—but I want it to look like the one on the right. if_(Cond1_1, % ( Cond1_1 Then1, % *=> Then1 if_(Cond2_1, % ; Cond2_1 Then2, % *=> Then2 if_(Cond3_1, % ; Cond3_1 Then3, % *=> Then3 if_(Cond4_1, % ; Cond4_1 Then4, % *=> Then4 if_(Cond5_1, % ; Cond5_1 Then5, % *=> Then5 Else5 % ; Else5 ) ) ) ) ). % ). To do the rewriting of (*=>)/2 to if_/3 in SWI-Prolog I