Re: Curry patterns

From: Nikolay Orlyuk <virkony_at_gmail.com>
Date: Wed, 15 Apr 2009 16:59:59 +0300

2009/4/15 Nikolay Orlyuk <virkony_at_gmail.com>

> Hi
>
> 2009/4/15 Гилмуллин Рушан <rus-reg_at_yandex.ru>
>
>> I have one question about Curry.
>>
>> I have two patterns
>>
>> parse s | s =:= <first pattern> = ...
>> parse s | s =:= <second pattern> = ...
>>
>> I want, the second match work only if the first match failed. But in fact
>> it don't dependence. If I do:
>>
>> parse s | s =:= <first pattern> = ...
>> parse s | (s =:= <first pattern>) =:= failed & s =:= <second pattern> =
>> ...
>>
>> this is don't work - the second pattern don't match if s =:= <first
>> pattern> march or no.
>>
>> If I do:
>> parse s | (s =:= <first pattern>) == success = ...
>> (s =:= <second pattern>) == success = ...
>> where ...
>> also bad: if first pattern fail, the second don't call.
>>
>> How to me to make so that the second match worked in only case when its
>> condition is satisfied, and the second match simultaneously fails?
>
> Before Curry I was in tight relations with Prolog. There was such thing
> like cutting ("!") alternatives. As I understand that is what you want -
> just to restrict alternatives. In curry that can be done at the upper level
> with use of "once" or "solveAll" or whatever you would like.
>
> I.e. if you want some kind of semideterministic (I like this term from
> Mercury) function you should wrap it like:
> parse_semidet s | once (parse s =:= r) = r where r free
>
Sorry.
parse_semidet s = findfirst (parse s =:=)



_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Do Apr 16 2009 - 09:11:13 CEST

This archive was generated by hypermail 2.3.0 : Do Feb 01 2024 - 07:15:09 CET