I know it doesn't exactly meet your desired syntax but mimicking the standard
library reads well and is consistent:
template maskIt(dt : DataTable, expr : untyped) : seq[bool] =
var result = newSeq[bool](dt.len)
for i in 0 ..< dt.len:
let it {.inject.} = (id:dt.id[i], name:dt.name[i], age:dt.age[i])
result[i] = expr
result
var x: DataTable
x = (id: @[1,2], name: @["john", "jeff"], age: @[30, 40])
echo maskIt(x, it.age >= 15 and isAlphaNumeric(it.name) )
echo maskIt(x, it.id == 1 )
- Inject the whole tuple into expression cdome
- Re: Inject the whole tuple into expression Araq
- Re: Inject the whole tuple into expression JohnS
