Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Jensens-Device/E/jensens-device-1.e
Normal file
14
Task/Jensens-Device/E/jensens-device-1.e
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
pragma.enable("one-method-object") # "def _.get" is experimental shorthand
|
||||
def sum(&i, lo, hi, &term) { # bind i and term to passed slots
|
||||
var temp := 0
|
||||
i := lo
|
||||
while (i <= hi) { # E has numeric-range iteration but it creates a distinct
|
||||
temp += term # variable which would not be shared with the passed i
|
||||
i += 1
|
||||
}
|
||||
return temp
|
||||
}
|
||||
{
|
||||
var i := null
|
||||
sum(&i, 1, 100, def _.get() { return 1/i })
|
||||
}
|
||||
6
Task/Jensens-Device/E/jensens-device-2.e
Normal file
6
Task/Jensens-Device/E/jensens-device-2.e
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
def sum(lo, hi, f) {
|
||||
var temp := 0
|
||||
for i in lo..hi { temp += f(i) }
|
||||
return temp
|
||||
}
|
||||
sum(1, 100, fn i { 1/i })
|
||||
Loading…
Add table
Add a link
Reference in a new issue