Sunday, February 28, 2021

Re: Vim9: call function from variadic function?

:h curly-braces-names

--
Stan Brown
Tehachapi, CA, USA
https://BrownMath.com
https://OakRoadSystems.com

On 2021-02-28 06:14, Lifepillar wrote:
> This might be a bit of a stretch, but... is it possible to
> "expand/split" variable arguments to call another function with fixed
> arguments? I would like to define a function that takes as input another
> function F and some values v1, vn... , and applies F to v1, ..., vn.
>
> For example, I can define:
>
> def F(a: string, b: number)
> enddef
>
> def G(...values: list<any>): void
> F(values[0], values[1])
> enddef
>
> G('xyz', 42)
>
> I would like to generalize G so that it can invoke any function, i.e.:
>
> def G2(F: func, ...values: list<any>): void
> F(XXXX)
> enddef
>
> G2(F, 'xyz', 42)
>
> The problem is: what can I put in place of XXXX? F(values) doesn't cut
> it.
>
> Thanks,
> Life.
>
>

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/12083587-0eff-07d8-b345-8d3fafd07d9b%40fastmail.fm.

No comments: