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

Rearrange at indices builtin #537

Closed
chunkybanana opened this issue Dec 29, 2021 · 9 comments · Fixed by #816
Closed

Rearrange at indices builtin #537

chunkybanana opened this issue Dec 29, 2021 · 9 comments · Fixed by #816
Labels
difficulty: average might have to get copilot out for this enhancement New feature or request need-more-info It's not a no, it's that we need just a little more information/details on what you are requesting. priority: medium Issues with medium priority request: element A request to create new element(s)

Comments

@chunkybanana
Copy link
Member

chunkybanana commented Dec 29, 2021

Something like (list, function, indices) ->

newvals = function(map(lambda a:list[a], indices))
for i in range(len(indices)):
  list[indices[i]] = newvals[i]
@chunkybanana chunkybanana added enhancement New feature or request difficulty: average might have to get copilot out for this priority: medium Issues with medium priority request: element A request to create new element(s) labels Dec 29, 2021
@cgccuser
Copy link
Member

APL has @ which is kinda like this

@zoomlogo
Copy link
Member

I think Jelly has something similar.

@razetime
Copy link
Collaborator

this fits a generalized primitive, which is apply at indices, which fits another generalized primitive which is called Under. apply at indices seems like a decent fit for golfing.

@lyxal
Copy link
Member

lyxal commented Jan 24, 2022

¨M already does something like this.

@lyxal lyxal closed this as completed Jan 24, 2022
@chunkybanana
Copy link
Member Author

¨M already does something like this.

No it really doesn't.

@chunkybanana chunkybanana reopened this Jan 25, 2022
@lyxal lyxal added the need-more-info It's not a no, it's that we need just a little more information/details on what you are requesting. label Mar 20, 2022
@lyxal
Copy link
Member

lyxal commented Mar 20, 2022

What type is indices? Also,

map(indices,lambda a:list[a])

isn't how map works. It takes lambda then iterable.

@lyxal
Copy link
Member

lyxal commented Mar 20, 2022

And if you had to give a one line description of what this does, what would it be?

@chunkybanana for this and the above.

@chunkybanana
Copy link
Member Author

Indices is an integer list, I guess? I'm bad at python.

"Call a function on all elements at specified indices together and put that back in the list"?

BTW, this should be 1 byte because it's a function element and we have the space.

@lyxal
Copy link
Member

lyxal commented Mar 20, 2022

Of course, it's going to be an overload of ¢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: average might have to get copilot out for this enhancement New feature or request need-more-info It's not a no, it's that we need just a little more information/details on what you are requesting. priority: medium Issues with medium priority request: element A request to create new element(s)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants