Commit 799a7182 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-01-31 01:55:37 by beppe] Empty log message

Original author: beppe
Date: 2004-01-31 01:57:29+00:00
parent b330f1fb
......@@ -123,7 +123,7 @@ thus discard, the rest of a sequence. This is nothing but a particular regular e
to bind the sequence captured by a (pattern) regular expression to a variable. But since a regexp is not a type, we cannot write, say, <code>x&amp;Tel+</code>. So we introduce a special notation <code>x::%%R%%</code> to bind <code>x</code> to the sequence matched by the type regular expression <code>%%R%%</code>. For instance:
</p>
<sample><![CDATA[
let domain (Email->String) <_>[ _*? d::(Echar+ '.' Echar+) ] -> d
let domain (Email ->String) <_>[ _*? d::(Echar+ '.' Echar+) ] -> d
]]></sample>
<p>
returns the last two parts of the domain of an e-mail (the <code>*?</code>
......
......@@ -115,7 +115,7 @@ The form <code>let x&amp;%%t%% = %%e%% in %%e'%%</code> is used so often that we
<sample><![CDATA[
let x : %%t%% = %%e%% in %%e'%%
]]></sample>
Note the blank spaces around the colon: this is because the XML recommendation allows colons to occur in identifiers (see the section on <a href="namespaces.html">namespaces</a>).
Note the blank spaces around the colon: this is because the XML recommendation allows colons to occur in identifiers: see the section on <a href="namespaces.html">namespaces</a> (the same holds to for the functional arrow <code>-></code> which must be surrounded by blanks).
</box>
<box title="XML documents" link="xml">
......
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page name="tutorial_higherorder">
<title>Higher-order functions</title>
<left>
<boxes-toc/>
<p>
You can cut and paste the code on this page and
test it on the <a href="cgi-bin/cduce">online interpreter</a>.
</p>
</left>
<box title="Introduction" link="intro">
<p><b style="color:#FF0080">TO BE DONE</b></p>
</box>
<box title="A complex example" link="comp">
<p> <b style="color:#FF0080">Rewrite in order not to introduce new type declarations</b>
</p>
<sample><![CDATA[
type Program = <program>[ Day* ]
type Day = <date day=String>[ Invited? Talk+ ]
type Invited = <invited>[ Title Author+ ]
type Talk = <talk>[ Title Author+ ]
type Author = <author> String
type Title = <title> String
let patch_program
(p :[Program], f :{{(Invited -> Invited) & (Talk -> Talk)}}):[Program] =
xtransform p with (Invited | Talk) & x -> [ (f x) ]
let first_author ({{[Program] -> [Program];
Invited -> Invited;
Talk -> Talk}})
| [ Program ] & p -> patch_program (p,first_author)
| <(k)>[ t a _* ] -> <(k)>[ t a ]
]]></sample>
</box>
</page>
......@@ -20,7 +20,7 @@ test it on the <a href="cgi-bin/cduce">online interpreter</a>.
<box title="Handling optional attributes" link="optatrr">
<p>
The blend of type type constructors and boolean combinator can be used to
reduce verbosity in writing pattern matching. As an exmple we show how to handle
reduce verbosity in writing pattern matching. As an example we show how to handle
tags with several optional attibutes.
</p>
<p>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment