Skip to content

Commit

Permalink
correction $self -> $this
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Dec 22, 2023
1 parent ee2bccc commit fd886fa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions specifications/xquery-40/src/expressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9711,7 +9711,7 @@ return $incrementors[2](4)]]></eg>
method call.</p></note>

<example id="id-example-method-updating">
<head>Example of an updating method</head>
<head>Updating methods</head>
<p>The following example demonstrates how a method might be used to increase
the size of a rectangle by a given factor.</p>

Expand Down Expand Up @@ -9739,24 +9739,24 @@ declare function geo:rectangle(
<p>Methods can be used to deliver recursive inline functions, as shown in the example below.</p>

<example id="id-example-method-recursve">
<head>Example of recursive method</head>
<head>Recursive methods</head>
<p>The following example implements an anonymous function that computes
the product of sequence of numbers:</p>

<eg><![CDATA[let $product :=
map{"_product": %method fn($in) {
if (empty($in))
then 1
else head($in) * $self?_product(tail($in))}
else head($in) * $this?_product(tail($in))}
}?_product
return $product((1.05, 1.04, 1.03))]]></eg>

<p>The next example illustrates a library of functions that are mutually
recursive:</p>

<eg><![CDATA[let $lib :=
map{"even": %method fn($val) {$val = 0 or $self?odd(abs($val)-1)},
"odd": %method fn($val) {not($self?even($val))}
map{"even": %method fn($val) {$val = 0 or $this?odd(abs($val)-1)},
"odd": %method fn($val) {not($this?even($val))}
}
return $lib?odd(23)]]></eg>
</example>
Expand Down

0 comments on commit fd886fa

Please sign in to comment.