On 8/12/22 7:41 AM, Yegappan Lakshmanan wrote:
Hi all,

The index() function returns the lowest index in a List where an item
has a value equal to the supplied expression.  This function cannot be
used to find an item with a specific key/value pair in a List of Dicts
(or to use a custom search in a List). You need to resort to using a
for loop  to find the index.

What do you think about extending the index() function to accept a
lambda function (similar to map(), filter() and reduce())?  This lambda
function will be called with two arguments: the index of the item and the
value of the item.  If this function returns true, then the search will stop.

Currently the index() function accepts four arguments (the first two
arguments are mandatory and the last two arguments are optional).  To
support using a lambda function, a fifth optional argument 'eval' needs
to be added. If this is true, then the second 'expr' argument will be
evaluated. It would have been simpler to add new arguments if the third
argument is a Dict.

How about if the 3rd argument is a dict, then there are only/exactly three arguments and the dict specifies optional parameters? The old definition is unchanged with 2+2.

-erniee


Regards,
Yegappan


--
--
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/75d94fae-aedc-9544-6b3a-b57aed94ddb7%40raelity.com.

Raspunde prin e-mail lui