First-class functions: Difference between revisions

(Added Dyalect programming language)
Line 1,970:
0.4999999999999999
0.5</pre>
 
=={{header|Objeck}}==
<lang objeck>use Collection.Generic;
 
lambdas Func {
Double : (FloatHolder) ~ FloatHolder
}
 
class FirstClass {
function : Main(args : String[]) ~ Nil {
vector := Vector->New()<Func2Holder<FloatHolder, FloatHolder> >;
# store functions in collections
vector->AddBack(Func2Holder->New(\Func->Double : (v)
=> v * v)<FloatHolder, FloatHolder>);
# new function from preexisting function at run-time
vector->AddBack(Func2Holder->New(\Func->Double : (v)
=> Float->SquareRoot(v->Get()))<FloatHolder, FloatHolder>);
# process collection
each(i : vector) {
# return value of other functions and pass argument to other function
Show(vector->Get(i)<Func2Holder>->Get()<FloatHolder, FloatHolder>);
};
}
function : Show(func : (FloatHolder) ~ FloatHolder) ~ Nil {
func(13.5)->Get()->PrintLine();
}
}</lang>
 
=={{header|OCaml}}==
760

edits