ERROR: syntax: extra token "for" after end of expression

I think what you’re looking for is (f(i, i) for i=1:3). These are known as generators, and they require parentheses when used directly inside of a code block.

Note that generators are lazy sequences of values; if you want to materialize a vector, you can replace the () with []: [f(i, i) for i=1:3].

3 Likes