RosettaCodeData/Task/Higher-order-functions/Fantom/higher-order-functions.fantom

15 lines
312 B
Text
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
class Main
{
// apply given function to two arguments
static Int performOp (Int arg1, Int arg2, |Int, Int -> Int| fn)
{
fn (arg1, arg2)
}
public static Void main ()
{
echo (performOp (2, 5, |Int a, Int b -> Int| { a + b }))
echo (performOp (2, 5, |Int a, Int b -> Int| { a * b }))
}
}