Both sides previous revision
Poprzednia wersja
Nowa wersja
|
Poprzednia wersja
|
pl:miw:miw08_xtt_rif:obsolate [2008/05/16 20:33] miw |
pl:miw:miw08_xtt_rif:obsolate [2019/06/27 15:50] (aktualna) |
... | ... |
</Atom> | </Atom> |
</then></code>| | </then></code> |
| |
| === Przykład 1: calculations (factorial) === |
| <code> |
| |----------------------------------------------------| |
| | | |
| | x s || s | |
| |->------------ x y s || y | |
| NA ||=x --+------> ------------------- | |
| >0 ||=s-1 --| || | |
| >0 >0 || =y*s -----| |
| =0 || =1 -----------| |
| >0 =1 || -----------+------> |
| </code> |
| <code xml> |
| <Group id="xtt_table1"> |
| <sentence id="xtt_table1_row1"> |
| <Implies> |
| <if> |
| <External> |
| <content> |
| <Atom> |
| <op><Const type="rif:iri">fn:is_empty</Const></op> |
| <arg><Var>x</Var></arg> |
| </Atom> |
| </content> |
| </External> |
| </if> |
| <then> |
| <Atom> |
| <op><Const type="rif:iri">xtt:concl</Const></op> |
| <arg> |
| <External> |
| <content> |
| <Expr> |
| <op><Const type="rif:iri">xtt:next_table</Const></op> |
| <arg><Const type="xsd:string">xtt_table2</Const></arg> |
| </Expr> |
| </content> |
| </External> |
| </arg> |
| <arg> |
| <External> |
| <content> |
| <Expr> |
| <op><Const type="rif:iri">op:assign</Const></op> |
| <arg><Var>s</Var></arg> |
| <arg><Var>x</Var></arg> |
| </Expr> |
| </content> |
| </External> |
| </arg> |
| </Atom> |
| </then> |
| </Implies> |
| </sentence> |
| |
| <sentence id="xtt_table1_row2"> |
| <Implies> |
| <if> |
| <External> |
| <content> |
| <Atom> |
| <op><Const type="rif:iri">op:numeric-greater-than</Const></op> |
| <arg><Var>s</Var></arg> |
| <arg><Const type="xsd:decimal">0</Const></arg> |
| </Atom> |
| </content> |
| </External> |
| </if> |
| <then> |
| <Atom> |
| <op><Const type="rif:iri">xtt:concl</Const></op> |
| <arg> |
| <External> |
| <content> |
| <Expr> |
| <op><Const type="rif:iri">xtt:next_table</Const></op> |
| <arg><Const type="xsd:string">xtt_table2</Const></arg> |
| </Expr> |
| </content> |
| </External> |
| </arg> |
| <arg> |
| <External> |
| <content> |
| <Expr> |
| <op><Const type="rif:iri">op:assign</Const></op> |
| <arg><Var>s</Var></arg> |
| <arg> |
| <External> |
| <content> |
| <Expr> |
| <op><Const type="rif:iri">op:numeric-substract</Const></op> |
| <arg><Var>s</Var></arg> |
| <arg><Const type="xsd:decimal">1</Const></arg> |
| </Expr> |
| </content> |
| </External> |
| </arg> |
| </Expr> |
| </content> |
| </External> |
| </arg> |
| </Atom> |
| </then> |
| </Implies> |
| </sentence> |
| </Group> |
| |
| <Group id="xtt_table2"> |
| <sentence id="xtt_table2_row1"> |
| <Implies> |
| <if> |
| <And> |
| <formula> |
| <External> |
| <content> |
| <Atom> |
| <op><Const type="rif:iri">op:numeric-greater-than</Const></op> |
| <arg><Var>x</Var></arg> |
| <arg><Const type="xsd:decimal">0</Const></arg> |
| </Atom> |
| </content> |
| </External> |
| </formula> |
| <formula> |
| <External> |
| <content> |
| <Atom> |
| <op><Const type="rif:iri">op:numeric-greater-than</Const></op> |
| <arg><Var>s</Var></arg> |
| <arg><Const type="xsd:decimal">0</Const></arg> |
| </Atom> |
| </content> |
| </External> |
| </formula> |
| </And> |
| </if> |
| <then> |
| <Atom> |
| <op><Const type="rif:iri">xtt:concl</Const></op> |
| <arg> |
| <External> |
| <content> |
| <Expr> |
| <op><Const type="rif:iri">xtt:next_table</Const></op> |
| <arg><Const type="xsd:string">xtt_table1</Const></arg> |
| </Expr> |
| </content> |
| </External> |
| </arg> |
| <arg> |
| <External> |
| <content> |
| <Expr> |
| <op><Const type="rif:iri">op:assign</Const></op> |
| <arg><Var>y</Var></arg> |
| <arg> |
| <External> |
| <content> |
| <Expr> |
| <op><Const type="rif:iri">op:numeric-multiply</Const></op> |
| <arg><Var>y</Var></arg> |
| <arg><Var>s</Var></arg> |
| </Expr> |
| </content> |
| </External> |
| </arg> |
| </Expr> |
| </content> |
| </External> |
| </arg> |
| </Atom> |
| </then> |
| </Implies> |
| </sentence> |
| |
| <sentence id="xtt_table1_row2"> |
| <Implies> |
| <if> |
| <Equal> |
| <side><Var>x</Var></side> |
| <side><Const type="xsd:decimal">0</Const></side> |
| </Equal> |
| </if> |
| <then> |
| <Atom> |
| <op><Const type="rif:iri">xtt:run_many</Const></op> |
| <arg> |
| <External> |
| <content> |
| <Expr> |
| <op><Const type="rif:iri">op:assign</Const></op> |
| <arg><Var>y</Var></arg> |
| <arg><Const type="xsd:decimal">1</Const></arg> |
| </Expr> |
| </content> |
| </External> |
| </arg> |
| <arg> |
| <External> |
| <content> |
| <Expr> |
| <op><Const type="rif:iri">xtt:return</Const></op> |
| <arg><Var>s</Var></arg> |
| <arg><Var>x</Var></arg> |
| <arg><Var>y</Var></arg> |
| </Expr> |
| </content> |
| </External> |
| </arg> |
| </Atom> |
| </then> |
| </Implies> |
| </sentence> |
| |
| <sentence id="xtt_table2_row3"> |
| <Implies> |
| <if> |
| <And> |
| <formula> |
| <External> |
| <content> |
| <Atom> |
| <op><Const type="rif:iri">op:numeric-greater-than</Const></op> |
| <arg><Var>x</Var></arg> |
| <arg><Const type="xsd:decimal">0</Const></arg> |
| </Atom> |
| </content> |
| </External> |
| </formula> |
| <formula> |
| <Equal> |
| <side><Var>s</Var></side> |
| <side><Const type="xsd:decimal">1</Const></side> |
| </Equal> |
| </formula> |
| </And> |
| </if> |
| <then> |
| <Atom> |
| <op><Const type="rif:iri">xtt:return</Const></op> |
| <arg><Var>s</Var></arg> |
| <arg><Var>x</Var></arg> |
| <arg><Var>y</Var></arg> |
| </Atom> |
| </then> |
| </Implies> |
| </sentence> |
| |
| </Group> |
| </code> |
| Obie tablice w formacie xml: {{:pl:miw:miw08_xtt_rif:factorial.xml|factorial.xml}}, {{:pl:miw:miw08_xtt_rif:factorial1.xml|factorial1.xml}} |
| ---- |
| Powyższy przykład został zwalidowany za pomocą dostępnych arkuszy XSD. Jedyny element, który zgłasza błędy jest to parametr ''id'', aczkolwiek ze względu na brak walidacji niektórych przykładów obecnych w dokumentacji, nie należy się tym przejmować. Nigdzie w dokumentacji nie ma wyraźnego zakazu wykorzystywania elementów standardu XML. |