RosettaCodeData/Task/First-class-functions/Lambdatalk/first-class-functions.lambd...

15 lines
352 B
Plaintext

{def cube {lambda {:x} {pow :x 3}}}
{def cuberoot {lambda {:x} {pow :x {/ 1 3}}}}
{def compose {lambda {:f :g :x} {:f {:g :x}}}}
{def fun sin cos cube}
{def inv asin acos cuberoot}
{def display {lambda {:i}
{br}{compose {nth :i {fun}}
{nth :i {inv}} 0.5}}}
{map display {serie 0 2}}
Output:
0.5
0.49999999999999994
0.5000000000000001