Syntax

"if" Strategy "then" Strategy "else" Strategy "end" -> Strategy

Description

<if s1 then s2 else s3 end> t

If s1 succeeds then strategy s2 is applied. If s1 fails, then s3 is applied.

The result of condition is ignored. If the condition succeeds, then the result is

<s2> t

If the condition fails, then the result is

<s3> t

Formatting

The if then else construct is usally formatted in the following way:

if s1 then
  s2
else
  s3
end

Implementation

The if-then-else construct is sugar for a guarded left-choice. The strategy

if s1 then s2 else s3 end
translates into

where(s1) < s2 + s3

Revision: r1.2 - 28 Apr 2005 - 22:24 - Main.wiki
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback