RosettaCodeData/Task/Currying/M2000-Interpreter/currying-2.m2000

27 lines
836 B
Plaintext

Module Puzzle {
Global Group F2 {
Sum=0
Sum2=0
Function Add (x){
.Sum+=x
=x
}
}
F1=lambda -> {
if empty then exit
Read x
Print ">>>", F2.Sum
F2.Sum2++ ' add one each time we read x
=x+lambda(![])
}
Link F2.Add() to F2()
P=F1(F1(F1(F2(2)),F2(2), F1(F2(2))),F2(2))=8
Print F2.Sum=8
Print F2.Sum2=7
\\ We read 7 times x, but we get 8, 2+2+2+2
\\ So 3 times x was zero, or not?
\\ but where we pass zero?
\\ zero return from F1 if no argument pass, so how x get zero??
}
Puzzle