mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-02-08 12:31:09 +00:00
Clean up lambda example
This commit is contained in:
parent
e23d45f34d
commit
76038502c8
14
README.md
14
README.md
@ -1042,8 +1042,12 @@ A Lambda function is a simple, anonymous function that can be passed to a functi
|
||||
```
|
||||
|
||||
def whatop(a, b, op)
|
||||
puti(a); puts(" ? "); puti(b); puts(" = ")
|
||||
puti(op(a, b); putln
|
||||
puti(a)
|
||||
puts(" ? ")
|
||||
puti(b)
|
||||
puts(" = ")
|
||||
puti(op(a, b))
|
||||
putln
|
||||
end
|
||||
|
||||
def lambdas
|
||||
@ -1053,10 +1057,10 @@ def lambdas
|
||||
|
||||
lambda1 = &(a, b) a + b
|
||||
lambda2 = &(a, b) (a + b, a - b)
|
||||
x = lambda1(1, 2)#1 // This will return 3
|
||||
x, y = lambda2(3, 4)#2 // This will return 7, -1
|
||||
x = lambda1(1, 2)#1 // This will return 3
|
||||
x, y = lambda2(3, 4)#2 // This will return 7, -1
|
||||
whatop(10, 20, &(a, b) a * b) // This will print 10 ? 20 = 200
|
||||
return &(x, y, z) x * z / y // You can even return lambdas from definitions
|
||||
return &(x, y, z) x * z / y // You can even return lambdas from definitions
|
||||
end
|
||||
````
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user