Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: prepend singleton dimensions to array with [;;;A] #43407

Open
BioTurboNick opened this issue Dec 12, 2021 · 2 comments
Open

Idea: prepend singleton dimensions to array with [;;;A] #43407

BioTurboNick opened this issue Dec 12, 2021 · 2 comments
Labels
arrays [a, r, r, a, y, s]

Comments

@BioTurboNick
Copy link
Contributor

BioTurboNick commented Dec 12, 2021

In the new array syntax in 1.7, we have this:

A = [1 2; 3 4]
[A;;;] # turn A into an array with at least 3-dimensions with appended singleton dimensions
#=
2×2×1 Array{Int64, 3}:
[:, :, 1] =
 1  2
 3  4
=#

And in 1.8 we'll also have #41618:

[;;;] # make empty 3-dimensional array

Based on a Slack chat, perhaps we could also have:

[;;;A] # turn A into an array with at least 3-dimensions with prepended singleton dimensions
@Ramanathi
Copy link

Ramanathi commented Dec 15, 2021

@BioTurboNick

A = [1 2; 3 4]
[;;;A] 
#=
1×2×2 Array{Int64, 3}:
[1, :, :] =
 1  2
 3  4
=#

do you want to achieve this ?
I'm new here, I want to try my hand on this ?

@dkarrasch dkarrasch added the arrays [a, r, r, a, y, s] label Dec 15, 2021
@BioTurboNick
Copy link
Contributor Author

BioTurboNick commented Dec 16, 2021

@Ramanathi - if you'd like to try, you could. It would require diving into the femtolisp-based parser. It'll be a challenge though, and no guarantee the Powers That Be would think this is a good idea.

Though the output would look like:

#=
1×2×2 Array{Int64, 3}:
[:, :, 1] =
 1  3

[:, :, 2] =
 2  4
=#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s]
Projects
None yet
Development

No branches or pull requests

3 participants