Vim9 Create its own Lambda Def Function

6 views
Skip to first unread message

N i c o l a s

unread,
Jan 11, 2023, 3:33:09 PM1/11/23
to vim_use
Hi,

Is it possible to create its own lambda function ?

I explain I got this def func :

def OutBufAdd(outbuf: list<string>, str: string)
  EchoMsg(str)
  outbuf->add(str)
enddef

Client code is using it as this :
OutBufAdd(outbuf, 'foo')
....
OutBufAdd(outbuf, 'bar')
....
OutBufAdd(outbuf, 'barfoofoo')
....
OutBufAdd(outbuf, 'barbar')

Regarding this, it is always in this case OutBufAdd(outbuf, somestring)

Is it possible to modify OutBufAdd(outbuf,  somestring  ) to OutBufAdd->(somestring) ?

Thank you for all
Nicolas



Salman Halim

unread,
Jan 11, 2023, 4:02:30 PM1/11/23
to vim...@googlegroups.com
:help Partial

You should be able to do this or a variation thereof from here:

var Adder: func: any = function('OutBufAdd', [outfbuf])

Adder(something)

Hope this helps,

Salman 

N i c o l a s

unread,
Jan 11, 2023, 4:18:45 PM1/11/23
to vim_use
Yess a lot it helps. Thank you Mr Halim.

Big Thank to Bram.
Reply all
Reply to author
Forward
0 new messages