mndrix / sweet

Sugar to make Prolog a little sweeter
The Unlicense
6 stars 0 forks source link

ternary operator #2

Open mndrix opened 10 years ago

mndrix commented 10 years ago

Similar to the one in C-descended languages. Syntax here borrowed from Ciao. Convert this

X = thing ? foo | bar.

into

(thing -> A = foo ; A = bar),
X = A.

Be sure that cascaded ternary expressions are supported:

fact(N, F) :-
   F = ( N = 0 ? 1
       | N > 0 ? N * fact(~ is N-1,~)
       ).

This construct is really an expression and in that sense it might fit well with library(func) which supports other types of expressions.