Thanks. Is the (top(endof)) syntax something that is exposed to the
user? Did not work for me:
julia> colon(1,(top(endof))([1:4;]))
ERROR: UndefVarError: top not defined
Would be nice when I need to construct the range generated by a lone :
in a macro.
Best,
Tamas
On Sat, Mar 14 2015, Matt Bauman wrote:
> On Saturday, March 14, 2015 at 9:15:32 AM UTC-4, Tamas Papp wrote:
>
> I don't know if the last step is accessible to the user (for
> metaprogramming), would be interesting to learn about that.
>
>
> Here you go:
>
> julia> expand(parse("x[:] += 1"))
> :(begin
> GenSym(0) = colon(1,(top(endof))(x))
> GenSym(1) = getindex(x,GenSym(0)) + 1
> setindex!(x,GenSym(1),GenSym(0))
> return GenSym(1)
> end)