Re: [eclipse-clp-users] Accessing Eclipse predicates

From: Sergii Dymchenko <kit1980_at_...6...>
Date: Fri, 16 Aug 2013 00:55:45 -0700
Hi Volcan,

Maybe this example will help you to understand how predicates ("functions"
that return "yes" or "no") work.

This example prints only integers (2, 4, 5). For every element A in a list
we check if predicate integer/1 is true ("returns yes"). If it is true, we
output the element using writeln. If it is false, we do nothing but return
'true', otherwise the whole loop will stop after first non-integer in the
list.

 main :-
   (foreach(A, [1.0, 2, "3", 4, 5]) do
        ( integer(A) ->
            writeln(A)
        ;
            true
        )
    ).

Sergii.


On Thu, Aug 15, 2013 at 8:37 PM, Volkan Unsal <spocksplanet@...6...>wrote:

> I mean the string(A) or integer(A). They return a yes or no on the
> commandline, but I am wondering if they can be used within the program as
> well.
>
>
>
> On Thu, Aug 15, 2013 at 11:19 PM, <mskala@...206...> wrote:
>
>> On Thu, 15 Aug 2013, Volkan Unsal wrote:
>> > Being new to Eclipse, I am trying to understand some basic concepts. I
>> don't
>> > understand why are some Eclipse predicates not available from inside
>> loops.
>> > For example:
>> > # test.ecl
>> > main :-
>> >   (foreach(A,[1,2]) do
>> >       Z is string(A),
>> >       writeln( Z )
>> >     ).
>>
>> It's nothing to do with loops.  "Z is string(A)" would be an error
>> outside a loop too; "is" is only for doing arithmetic.
>>
>> > These are available from the command line when I query the data, but not
>> > from within the program. How do I do type checking on the variables if I
>> > can't use these...?
>>
>> What exactly do you mean by "these"?  What are you typing on the
>> command line?
>>
>> --
>> Matthew Skala
>> mskala@...206...                 People before principles.
>> http://ansuz.sooke.bc.ca/
>
>
>
>
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>
>
Received on Fri Aug 16 2013 - 07:55:53 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:30 CEST