1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"949.43">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #000000}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #832519; min-height: 12.0px}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0021e7}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0047e4}
17 span
.s1
{font: 18.0px Helvetica
}
18 span
.s2
{color: #000000}
19 span
.s3
{font: 12.0px Helvetica
; color: #0021e7}
20 span
.s4
{font: 12.0px Helvetica
; color: #0024f8}
21 span
.s5
{font: 12.0px Helvetica
; color: #0047e4}
22 span
.s6
{font: 12.0px Helvetica
; color: #0000ff}
23 span
.s7
{color: #0000bf}
24 span
.s8
{color: #007300}
25 span
.Apple-tab-span
{white-space:pre
}
29 <p class=
"p1"><span class=
"s1"><b>UnaryOpFunction
<span class=
"Apple-tab-span"> </span></b></span><b>represent a unary oparation on a function
</b></p>
30 <p class=
"p2"><br></p>
31 <p class=
"p1"><b>superclass: AbstractFunction
</b></p>
32 <p class=
"p2"><br></p>
33 <p class=
"p1">Operating on functions instead of numbers, what results is not a result of the calculation, but a structure that represents that calculation.
</p>
34 <p class=
"p2"><br></p>
35 <p class=
"p3">// example
</p>
36 <p class=
"p3"><span class=
"s2">a =
2.sqrt;
</span>// result is square root of two (approximate floating point).
</p>
37 <p class=
"p3"><span class=
"s2">a = { b }.sqrt;
</span>// result is
<span class=
"Apple-converted-space"> </span>a UnaryOpFunction
</p>
38 <p class=
"p4">b =
2;
</p>
39 <p class=
"p3"><span class=
"s2">a.value;
</span>// now it is evaluated, and the result is calculated
</p>
40 <p class=
"p4">b =
9;
</p>
41 <p class=
"p3"><span class=
"s2">a.value;
</span>// again, with a different value.
</p>
42 <p class=
"p5"><br></p>
43 <p class=
"p6"><span class=
"s2">see also:
<a href=
"BinaryOpFunction.html"><span class=
"s3">BinaryOpFunction
</span></a>,
<a href=
"NAryOpFunction.html"><span class=
"s4">NAryOpFunction
</span></a></span></p>
44 <p class=
"p7"><span class=
"s2">related:
<a href=
"../Streams-Patterns-Events/UnaryOpStream.html"><span class=
"s5">UnaryOpStream
</span></a>,
<a href=
"../Streams-Patterns-Events/Patterns/Punop.html"><span class=
"s6">Punop
</span></a></span></p>
45 <p class=
"p2"><br></p>
46 <p class=
"p2"><br></p>
47 <p class=
"p3">// sound example
</p>
49 <p class=
"p4"><span class=
"s7">var
</span> a = {
19.rand };
</p>
50 <p class=
"p4"><span class=
"s7">var
</span> b = a.sqrt;
</p>
51 <p class=
"p4">fork {
</p>
52 <p class=
"p4"><span class=
"Apple-tab-span"> </span>15.do {
</p>
53 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(instrument:
<span class=
"s8">\default
</span>, note: [a.value, b.value]).play;
</p>
54 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0.3.wait;
</p>
55 <p class=
"p4"><span class=
"Apple-tab-span"> </span>}
</p>