How do I do this:
select colA,enlist “” from tableA
or
select colA,enlist “abc” from tableA
I get a length error in both cases.
How do I do this:
select colA,enlist “” from tableA
or
select colA,enlist “abc” from tableA
I get a length error in both cases.
this works, but there is probably a shorter way of defining d :
1 3 abc “ab”
2 3 abc “ab”
3 3 abc “ab”
ta, jack
A bit more idiomatic to use count[i], but otherwise I dont know of anything shorter.
Cheers,
? Attila
very nice thankyou
much nicer - but there is a speed difference (at least on my ancient box):
q)\t t:(x:til 1000000);do[100;(d:enlist"abc") cross t]
1393
q)\t t:(x:til 1000000);do[100;select x,d:(count t)#enlist “abc” from t]
780
but i don’t understand why i get different counts here:
q)count select x,d:(count t)#enlist “abc” from t
1000000
q)count select d:(count t)#enlist “abc” from t
1
q checks only the first expression in the select to derive shape for the result.
maybe you want to use update for such a scenario anyway (it can derive the shape from the target)
q)count update d:count[i]#1 from (til 10)
10
Another solution, takes around the same time
q)\t t:(x:til 1000000);do[100;select x,b:(count t)#enlist “abc” from t]
1658
q)\t t:(x:til 1000000);do[100;t^(b:count[t]#enlist"abc")]
1625
q)\t count[t]#enlist"abc"
dominates
,’ is less work than ^
t,'(b:count[t]#enlist"abc")