Hi,
A bit puzzled here… Say I have a table comprised of 2 columns, with the first one made of variable length lists, and the second showing a binary:
<font face='"terminal,monaco"'>t:([] a:{x?50} each 2+100000?100; b:100000?0b)</font>
I want to apply a specific function to each list found in ta, depending on the binary t
b. In this example, let’s simply use <first> and <last> as dependant functions.
Below are 3 possible syntax versions and their time/memory consumption. I would have expected the <scan> version to beat the 2 others by a substantial factor, at least on timing (with +/- impact on memory). The reality seems to be the opposite:
Cond$ with Each
<font face='"terminal,monaco"'>q)\ts {$[x`b; last x`a; first x`a]} each t </font>
<font face='"terminal,monaco"'>40 3697968 </font>
Cond? with Each within function
<font face='"terminal,monaco"'>q)\ts {?[x`b; last each x`a; first each x`a]}t </font>
<font face='"terminal,monaco"'>16 4746672 </font>
Scan
<font face='"terminal,monaco"'>q)\ts ({?[y`b; last; first] y`a}\)[::;t] </font>
<font face='"terminal,monaco"'>62 12746416 </font>
Is there an issue with my wording of the scan version (4x slower, 2.5x memory hungry), or is the second one the actual optimal solution? As usual, your insight is highly appreciated. Thx.