RosettaCodeData/Task/First-class-functions-Use-numbers-analogously/E/first-class-functions-use-numbers-analogously.e
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

18 lines
357 B
Text

def x := 2.0
def xi := 0.5
def y := 4.0
def yi := 0.25
def z := x + y
def zi := 1.0 / (x + y)
def forward := [x, y, z ]
def reverse := [xi, yi, zi]
def multiplier(a, b) {
return fn x { a * b * x }
}
def s := 0.5
for i => a in forward {
def b := reverse[i]
println(`s = $s, a = $a, b = $b, multiplier($a, $b)($s) = ${multiplier(a, b)(s)}`)
}