- Mail actions: [ respond to this message ] [ mail a new topic ]
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]

From: Kish Shen <kish.shen_at_...6...>

Date: Thu, 17 Jun 2021 20:18:26 +0100

Date: Thu, 17 Jun 2021 20:18:26 +0100

Hi Doug, >How does this work? I don't understand how p(a,1) becomes numeric. I think maybe I did not fully understand your question in my previous reply. p(a, 1) is numeric because the last argument is numeric - The leturn value of the ast argument of p(a, 1), i.e. 1, replaces p(1) in the original expression, When ECLiPSe encounters p(a) when evaluating the expression, In place of p(a), p(a, Z) is called, and Z replaces p(a). Of course, if p/2 is not defined, or if the last argument does not return a numeric value, you will get a run-time error. The same applies to the built-in operators, like +/2: A is 3 + 4 is replaced by +(3, 4, Z), A = Z. You can see this when there is an error: [eclipse 28]: A is 4 + X. instantiation fault in +(4, X, _278) Abort Cheers, Kish On Thu, Jun 17, 2021 at 1:18 PM Doug Edmunds <dougedmunds_at_...6...> wrote: > > In the Apt/Wallace book Constraint Log Programming Using Eclipse (2007), > Ch 3 "Arithmetic in Prolog" on pages 45-46 there is this code: > ------- > To save explicitly introducing such extra variables, ECLiPSe supports > for is/2 a functional syntax. Let us suppose p/2 is a predicate whose > last argument is numeric, viz. > > p(a, 1). > p(b, 2). > > Then p/1 can be used as a function when it occurs on the right-hand side > of is, for example: > > [eclipse 10]: X is p(a)+1. > > X = 2 > Yes (0.00s cpu) > > -------- > > How does this work? I don't understand how p(a,1) becomes numeric. > > Can you point me to some reference to "predicate whose last > argument is numeric" in the manuals? > > Thanks. > > -DAE > > > > _______________________________________________ > ECLiPSe-CLP-Users mailing list > ECLiPSe-CLP-Users_at_lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/eclipse-clp-usersReceived on Thu Jun 17 2021 - 19:18:48 CEST

*
This archive was generated by hypermail 2.3.0
: Wed Sep 25 2024 - 15:13:21 CEST
*