-
Notifications
You must be signed in to change notification settings - Fork 160
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
Syntax extension: unpacking argument lists #2043
Comments
BTW, this could of course also be extended to other contexts, to give some form of "list interpolation" (if that's the right term). E.g. And of course one could also use So, (The syntax with |
I like this, definately for function calls, and then it would be natural to have it in lists too. Talking about notation (sorry!), the other option would be |
I think this feature would be really useful. |
BTW, another idea would be to also allow interpolation for records. I think I can explain it best with an example (here I am using
So one could "merge" records this way. This is useful if one wants to implement options via records, and give default values. You can write this:
That said, I am not sure record interpolation would be quite as useful as list interpolation. It could become more interesting if we ever want to add keyword arguments (see feature request issue #1051), because then it would be natural to also allow this for function calls:
|
Somewhat dually to #40, I often wish there was a shorter way to call a function with a given list of arguments than
CallFuncList(func, list)
. And quite often I also would like to do something likeCallFuncList(func, Concatenation([true], list, [42]))
, i.e. prepend or append some arguments.In Python, this is solved by Unpacking Argument Lists. A hypothetical GAP adaption might look like this:
Then I could e.g. write
List(Collected(FactorsInt(n)), pn -> \^(*pn));
to get a list of the maximal primer power divisors ofn
. That's a somewhat artificial example, of course, but I have had need for something like this plenty of times.Actually, what I'd also quite often use is a variant of
List
which uses*
when it invokes the function. SayThe text was updated successfully, but these errors were encountered: