What's your simple thing that you'd like to be easier than it is?

Oh yes I know about list comprehension, but the syntax means I only use them for the shortest things. Although this functionality is very useful for longer blocks as well. Maybe I could make a macro that just converts a map-like expression into a list comprehension with if clauses.

Speaking of comprehensions, I wish

julia> [name.(cr.students)... for cr in classrooms]

would correspond to

julia> [student_name for cr in classrooms for student_name in name.(cr.students)]
1 Like

Whenever you would put a larger function body in a do block, you can also write a local function and use it as

## in some local scope
function _f(x, y)
    # do complicated stuff
end
function _g(x, y)
    # some complex condition
end
[_f(x, y) for (x, y) in zip(X, Y) if _g(x,y)]

Of course giving a descriptive name to _f and _g when possible will be even better style.

1 Like