[julia-users] Re: using subscripts \_1, \_2, ... as field names
I'm no macro expert, but I think one could parse the variable names in a macro to enable Tim Wheeler's as @subind Σ₁₁ to get Σ[1,1]
[julia-users] Re: using subscripts \_1, \_2, ... as field names
I see that most of the latex symbols representing digits cannot be used as variable/field name, (e.g., \msansone, \mbfone). I guess this is a deliberate choice, made to prevent disasters from happening when this kind of notation is over abused. I have to say though that there are probably a couple of cases where it would be useful, like the one I mentioned. On Tuesday, May 10, 2016 at 9:56:16 AM UTC+1, Davide Lasagna wrote: > > Hi, > > I have a custom type representing a bordered matrix (a big square matrix, > bordered by two vectors and a scalar in the bottom right corner), where the > four blocks are stored in separated chunks of memory. I would like to call > the fields of my type using subscripts \_1\_1, \_1\_2, ... so that I can > nicely access them as A.11, A.12, ... However, it seems that subscripts > (and superscripts) with digits can't be used for variable names, resulting > in a syntax error. Subscripts with letters work fine. > > Any thoughts on this? >
[julia-users] Re: using subscripts \_1, \_2, ... as field names
I would love to see a₁ automatically call getindex(a, 1). It would make math easier. I'd love to be able to write: b = μ₂ + Σ₁₂*(a₁ - μ₁)/Σ₁₁ Λ = Σ₂₂ - Σ₁₂*Σ₁₂/Σ₁₁ for μ::Vector{F<:Real} and Σ::Matrix{F<:Real} Σ could be accessed via Σ₁₁ to get Σ[1,1]. Of course this breaks down with digits larger than 9, but you probably don't want to be using this feature for such large values. On Tuesday, May 10, 2016 at 1:56:16 AM UTC-7, Davide Lasagna wrote: > > Hi, > > I have a custom type representing a bordered matrix (a big square matrix, > bordered by two vectors and a scalar in the bottom right corner), where the > four blocks are stored in separated chunks of memory. I would like to call > the fields of my type using subscripts \_1\_1, \_1\_2, ... so that I can > nicely access them as A.11, A.12, ... However, it seems that subscripts > (and superscripts) with digits can't be used for variable names, resulting > in a syntax error. Subscripts with letters work fine. > > Any thoughts on this? >