You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 9, 2020. It is now read-only.
Ciao (with :=) and GRIPS (with <-) and Mercury (with =) provide special syntax for defining predicates that behave like functions.
In both GRIPS and Mercury, function definition implies determinism. I think Ciao makes a mistake here by allowing nondeterministic predicates to be defined with functional notation.
Using functional definitions should imply determinism. Mercury's = should be enough syntax. I've never seen =/2 as a top level functor. So, assuming --/1 performs decrement, our definition should be
fact(0) = 1
fact(N) = N * fact(--N)
which desugars into
fact(0, F) :-
!,
F = 1.
fact(N, F) :-
succ(Nminus, N),
fact(Nminus, F0),
F is F0*N.
There's no protection against fact(-1) looping forever, but most functional languages don't protect against that either.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Ciao (with
:=
) and GRIPS (with<-
) and Mercury (with=
) provide special syntax for defining predicates that behave like functions.In both GRIPS and Mercury, function definition implies determinism. I think Ciao makes a mistake here by allowing nondeterministic predicates to be defined with functional notation.
Using functional definitions should imply determinism. Mercury's
=
should be enough syntax. I've never seen=/2
as a top level functor. So, assuming--/1
performs decrement, our definition should bewhich desugars into
There's no protection against
fact(-1)
looping forever, but most functional languages don't protect against that either.The text was updated successfully, but these errors were encountered: