Say, we have a function f which returns a vector of known size n with n>1.
Is it possible to access f(x)[1] without computing f(x) as a whole?
Say, we have a function f which returns a vector of known size n with n>1.
Is it possible to access f(x)[1] without computing f(x) as a whole?
There is not unless the vector returned by f is a lazy data structure—standard arrays contain already-computed values. If you want to return a lazy data structure, you can look at MappedArrays. If you don't want to return a lazy data structure, then you could refactor f to take an index to compute, so you would call it as f(x, 1) instead.