Multiple distinct objects: Difference between revisions
m
→{{header|Julia}}
mNo edit summary |
|||
Line 636:
=={{header|Julia}}==
A potential mistake would be writing:
▲<lang Julia>>
foo() = rand() # repeated calls change the result with each call
repeat([foo()], outer=5) # but this only calls foo() once, clones that first value
</lang>
If the effect of calling foo() with every iteration is desired, better to use:
<lang Julia>
[foo() for i in 1:5] # Code this to call the function within each iteration
|