Open dlealv opened 1 year ago
Timer take a ‘thunk’ as the first argument; a thunk is a zero argument lambda. It should be myLib.timer(LAMBDA(TEXTSPLIT(…)))
.
Thanks, I tested this option too. Now I just copied the following function to my workbook:
pair = LAMBDA(x_1,x_2, LAMBDA(j,switch(j,1,x_1,2,x_2)));
timer = LAMBDA(thunk,
LET( time_0, NOW()
, value, thunk()
, time_1, NOW()
, days, time_1 - time_0
, ms, days * 24 * 60 * 60 * 1000 // milliseconds (resolution 10ms on desktop)
, pair(round(ms,0),value)
)
);
and then execute the following:
@jack-williams I guess it should not give an error, but at least I found a way to use it, since it uses the pair
function output, you can use it as follows:
timer(LAMBDA(TEXTSPLIT(…)))(1)
which returns the time
timer(LAMBDA(TEXTSPLIT(…)))(2)
which returns TEXTSPLIT output
I don't think it is intended for the user's final function, you can use it as follows instead:
=LET(x,timer(LAMBDA(UPPER("hola"))), HSTACK(x(1), x(2)))
or even shorter:
=timer(LAMBDA(UPPER("hola")))({1,2})
but it doesn't work properly when the result is an array:
As you can see using HSTACK
works in both cases.
I forgot that the pair
function uses a function encoding. This is the problem. I think it would be better to replace this with HSTACK
now, which at the time was not available.
pair = LAMBDA(x_1,x_2, HSTACK(x_1, x_2));
fst = LAMBDA(p, INDEX(p, 1, 1));
snd = LAMBDA(p, INDEX(p, 1, 2));
I was able to run
go
LAMBDA function which usestimer
function. But when I try to call it alone I am getting an#CALC!
error:Thanks,