Function definition: Difference between revisions

Content added Content deleted
(PascalABC.NET)
Line 2,223: Line 2,223:
map times3, [1, 2, 3]</syntaxhighlight>
map times3, [1, 2, 3]</syntaxhighlight>


=== impure functions (I/O) ===
=== impure effects ===
Impure functions must be declared as such.
Functions with impure effects must be declared as such, using fn*.
<syntaxhighlight>val writeit = impure fn(x) { writeln x }</syntaxhighlight>
<syntaxhighlight>
val writeit = fn*(x) { writeln x }
</syntaxhighlight>


Impure functions cannot be passed to pure functions.
Impure functions cannot be passed to pure functions.