Anand.Kulkarni.SG
BAN USERThis will do in kdb :) short and sweet. the complexity is O(N^2) cant be reduced below that :)
{ { { t:delete from ([] a:1 2 3;b:4 5 6;s:1 2 3)
f1:{ { `t upsert ([] a:x;b:y;s:(x*x*x) + (y*y*y)); }[;y] each x }
f2:{ raze f1[;y] each x }[L1;L2]
p:select a, b by s from t
p:update ca:{count each x}[a] , cb:{count each x}[b] from p
select from p where ca>2 } } }
shortest answer is in kdb :) , the below finds all such occurances.
t:delete from ([] a:1 2 3;b:4 5 6;s:1 2 3)
f1:{ { `t upsert ([] a:x;b:y;s:(x*x*x) + (y*y*y)); }[;y] each x }
f2:{ raze f1[;y] each x }[L1;L2]
p:select a, b by s from t
p:update ca:{count each x}[a] , cb:{count each x}[b] from p
select from p where ca>2
This works perfectly without virtual and uses template technique and casting using passed parameter information. since without virtual we have no clue is base pointer is pointing to base object or derived instances of the base...The best is the do upcast via the template parameter passed.
The virtual solution also works just fine.
- Anand.Kulkarni.SG November 13, 2018