A
sum(f(x, y) for x in (-1, 1), y in (-1, 1)) can solve the problem?if x=y=1. that should put (1/2(1-k)) into sum(f(x,y))
Size: a a a
A
sum(f(x, y) for x in (-1, 1), y in (-1, 1)) can solve the problem?АО
A
VG
A
VG
return keyword to see, what result are you returning from a functionA
return keyword to see, what result are you returning from a functionVG
@show 1 + x@show y = 1 + xАО
function fun2()
res = 0
for x in (-1, 1)
for y in (-1, 1)
if x == y == 1
res += fun(x, y)*1/2(1-k)
else
res += fun(x, y)
end
end
end
return res
end
VG
x, y, because you redefine them as local variables in a loopA
function fun2()
res = 0
for x in (-1, 1)
for y in (-1, 1)
if x == y == 1
res += fun(x, y)*1/2(1-k)
else
res += fun(x, y)
end
end
end
return res
end
АО
АО
julia> fun2()
# some result
julia> println(fun2())
# REPL print some result
julia> println("My awesome function: $fun2()")
# My awesome function: <some result>АО
A
function fun2()
res = 0
for x in (-1, 1)
for y in (-1, 1)
if x == y == 1
res += fun(x, y)*1/2(1-k)
else
res += fun(x, y)
end
end
end
return res
end
АО
x, y, because you redefine them as local variables in a loop1 + 1 - 1АО
fun properly, it should return some value.VG
A
AM