ZenScript main repository
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

functions_lambdas.zs 413B

12345678910111213141516171819202122
  1. val outOfScope = 10;
  2. val fun1 = (a as int, b as int) as int => a + b * outOfScope;
  3. val fun2 = (a as int, c as int) as int => 13;
  4. function apply(fn as function(value as int) as int, scale as int) as int {
  5. return fn(scale);
  6. }
  7. println(fun1(30, 20));
  8. println(fun2(30, 20));
  9. function scale(value as int, scale as int) as int {
  10. return apply(v => v * scale, value);
  11. }
  12. println("Value: " + scale(10, 5));