Hello,
If I have a table -
a b c
1 2 3
6 4 2
5 5 1
How do I do something like this –
update myval: $[a<=b;[a];[c]] from
I want result like –
a b c myval
1 2 3 1
6 4 2 2
5 5 1 1
Thanks in Advance,
Ramdas
Hello,
If I have a table -
1 2 3
6 4 2
5 5 1
How do I do something like this –
update myval: $[a<=b;[a];[c]] from
I want result like –
1 2 3 1
6 4 2 2
5 5 1 1
Thanks in Advance,
Ramdas
update myval:(c*a>=b)+(a*a<b) from <table>?
2009/11/13 Ramdas <rthatte@gmail.com>
Hello,
If I have a table -
a ? b ? c
1 ? 2 ? 3
6 ? 4 ? 2
5 ? 5 ? 1How do I do something like this –
update myval: $[a<=b;[a];[c]] from <table>
I want result like –
a ? ?b ? ?c ? ?myval
1 ? ?2 ? ?3 ? ?1
6 ? ?4 ? ?2 ? ?2
5 ? ?5 ? ?1 ? ?1Thanks in Advance,
Ramdas
vector conditional
?[condition;true;false]
e.g.
update myval: ?[a<=b;a;c] from <table>
And if you need to apply a function to each row you can use the each-both adverb '.
1 2 3 1
6 4 2 2
5 5 1 1
In your case though, I would go with the vector conditional since that is much faster.
q)table:( a:1000?100; b:1000?100; c:1000?100)
q)\t do[10000;update myval:{$[x<y;x;z]}'[a;b;c] from table;]
2561
q)\t do[10000;update myval:?[a<b;a;c] from table;]
114
Thanks guys,Vector condition worked well.–RamdasOn Nov 13, 6:27?pm, Daniel Br?ndstr?m <daniel.brandst…>wrote:> And if you need to apply a function to each row you can use the each-both> adverb '.>> q)table:( a:1 6 5; b:2 4 5; c:3 2 1)> q)update myval:{$[x a b c myval> -----------> 1 2 3 1> 6 4 2 2> 5 5 1 1>> In your case though, I would go with the vector conditional since that is> much faster.>> q)table:( a:1000?100; b:1000?100; c:1000?100)> q)\t do[10000;update myval:{$[x 2561> q)\t do[10000;update myval:?[a 114>>>>>> On Fri, Nov 13, 2009 at 8:22 PM, Charles Skelton <char…> wrote:> > vector conditional>> > ?[condition;true;false]>> > e.g.>> > update myval: ?[a<=b;a;c] from
>> > On Fri, Nov 13, 2009 at 7:43 PM, Ramdas <rtha…> wrote:>> >> Hello,>> >> If I have a table ->> >> a ? b ? c> >> ------------> >> 1 ? 2 ? 3> >> 6 ? 4 ? 2> >> 5 ? 5 ? 1>> >> How do I do something like this –>> >> update myval: $[a<=b;[a];[c]] from