Jump to content

Partial function application: Difference between revisions

m
Line 631:
=={{header|Elena}}==
{{trans|Smalltalk}}
ELENA 3.4.x :
<lang elena>import system'collections.;
import system'routines.;
import extensions.;
public program()
{
[
var partial := (:afs:,af) => ((:s)( => afs(af, s))).;
var fs := (:f:s)(,s => s.selectBy(:x)(x => f(x)); .summarize(ArrayList new); toArrayArrayList()).toArray());
var f1 := (:x)( => x * 2).;
var f2 := (:x)( => x * x).;
var fsf1 := partial(fs, f1).;
var fsf2 := partial(fs, f2).;
console .printLine(fsf1((new int[]{2,4,6,8}).toString() toLiteral).;
console .printLine(fsf2((new int[]{2,4,6,8}).toString() toLiteral).
]}</lang>
{{out}}
<pre>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.