apply folding over rows of a table

Hi,(1st post so excuses in advance for the potential newbyness of thequestion)I’d like to fold a function, i.e. to use the over adverb (/) , foreach rows of a table.Here’s my try :unary_corporate_action:{[x;y] update price:price * ycoef from x wheredate \< ydate}; / for atbl unary_unary_corporate_action/ corporate_action;where tbl is a price table, and corporate_action is a table ofcorporate_actionWhat I’d wanted was to recursively apply the unary function to theinitial tblThe result is a 'nyi error message (not yet implemented)what’s the difference wrt a100 {2*x+y}/ 1 2 3that works?or wrt a{(x`price) +1} each tblthat also works?(well, there are obviously differences, but what particular pointmakes it “nyi”?)Do I have smarter alternatives than using a for loop?Many thanks in advanceJulien

Hi Julien,If I understand what you’re asking, you want a function to look atrows from two different tables and update a column in one of thetables.I don’t think your problem is with applying the function over a table,it’s with the usage of two tables in a single “update..from” query.You can reference another table in a table query if you use a sharedkey to look-up the row. For example if I have one table "tblprice"and another table “tblecoef”, I can do something very similar to yourupdate query like this:update price:price*tblcoef[(sym);coef] from tblpriceNotice the syntax for referencing the second table ("tblcoef") whendoing a query on tblprice.If I only wanted specific rows from tblcoef, I could query those firstand store them in a temporary table for use later, like this:tmptbl:select from tblcoef where sym in ABCDEFGHIJKLThen run the similar query as above:update price:price*1^tmptbl[([]sym);coef] from tblpriceBelow is an example I tried.Hope that helps.q)tblprice:(([sym:ABCDEFGHIJKLMNOPQRSTUQWERTYCVB]price:10+10?10f);q)tblpricesym| price—| --------ABC| 13.92752DEF| 15.17091GHI| 15.1598JKL| 14.06664MNO| 11.78084PQR| 13.01772STU| 17.85033QWE| 15.3471RTY| 17.11172CVB| 14.11597q)tblcoef:([sym:ABCDEFGHIJKLMNOPQRSTUQWERTYCVB]coef:10?1f)q)tblcoefsym| coef—| ----------ABC| 0.4931835DEF| 0.5785203GHI| 0.08388858JKL| 0.1959907MNO| 0.375638PQR| 0.6137452STU| 0.5294808QWE| 0.6916099RTY| 0.2296615CVB| 0.6919531q)update price:price*tblcoef[(sym);coef] from tblpricesym| price---| --------ABC| 6.868825DEF| 8.77668GHI| 1.271734JKL| 2.756931MNO| 4.42533PQR| 7.989564STU| 9.451407QWE| 10.6142RTY| 3.929903CVB| 9.767589On Mar 24, 9:18?am, Julien Laugel <jlau...> wrote:&gt; Hi,&gt; (1st post so excuses in advance for the potential newbyness of the&gt; question)&gt;&gt; I'd like to fold a function, i.e. to use the over adverb (/) , for&gt; each rows of a table.&gt;&gt; Here's my try :&gt; unary_corporate_action:{[x;y] update price:price * ycoef from x where> date < ydate}; ?/ for a&gt; tbl unary_unary_corporate_action/ corporate_action;&gt;&gt; where tbl is a price table, and corporate_action is a table of&gt; corporate_action&gt;&gt; What I'd wanted was to recursively apply the unary function to the&gt; initial tbl&gt;&gt; The result is a 'nyi ?error message (not yet implemented)&gt;&gt; what's the difference wrt a&gt; 100 {2*x+y}/ 1 2 3&gt; that works?&gt; or wrt a&gt; {(xprice) +1} each tbl> that also works?> (well, there are obviously differences, but what particular point> makes it “nyi”?)>> Do I have smarter alternatives than using a for loop?>> Many thanks in advance>> Julien</jlau…>

X-Mailer: Apple Mail (2.936)note that txf joins like this (so-called due to the older form of them which used the txf function) aren’t terribly performant. foreign key joins are much quicker.On Mar 26, 2010, at 7:20 PM, gabber wrote:> Hi Julien,> If I understand what you’re asking, you want a function to look at> rows from two different tables and update a column in one of the> tables.> I don’t think your problem is with applying the function over a table,> it’s with the usage of two tables in a single “update..from” query.> You can reference another table in a table query if you use a shared> key to look-up the row. For example if I have one table “tblprice”> and another table “tblecoef”, I can do something very similar to your> update query like this:> update price:price*tblcoef[(sym);coef] from tblprice\>\> Notice the syntax for referencing the second table ("tblcoef") when\> doing a query on tblprice.\> If I only wanted specific rows from tblcoef, I could query those first\> and store them in a temporary table for use later, like this:\> tmptbl:select from tblcoef where sym in ABCDEFGHIJKL\>\> Then run the similar query as above:\> update price:price*1^tmptbl[([]sym);coef] from tblprice>> Below is an example I tried.> Hope that helps.>> q)tblprice:(([sym:ABCDEFGHIJKLMNOPQRSTUQWERTYCVB]price: > 10+10?> 10f);> q)tblprice> sym| price> —| --------> ABC| 13.92752> DEF| 15.17091> GHI| 15.1598> JKL| 14.06664> MNO| 11.78084> PQR| 13.01772> STU| 17.85033> QWE| 15.3471> RTY| 17.11172> CVB| 14.11597>>> q)tblcoef:([sym:ABCDEFGHIJKLMNOPQRSTUQWERTYCVB]coef:10?1f)> q)tblcoef> sym| coef> —| ----------> ABC| 0.4931835> DEF| 0.5785203> GHI| 0.08388858> JKL| 0.1959907> MNO| 0.375638> PQR| 0.6137452> STU| 0.5294808> QWE| 0.6916099> RTY| 0.2296615> CVB| 0.6919531> q)update price:price*tblcoef[(sym);coef] from tblprice\> sym| price\> ---| --------\> ABC| 6.868825\> DEF| 8.77668\> GHI| 1.271734\> JKL| 2.756931\> MNO| 4.42533\> PQR| 7.989564\> STU| 9.451407\> QWE| 10.6142\> RTY| 3.929903\> CVB| 9.767589\>\>\>\> On Mar 24, 9:18 am, Julien Laugel <jlau...> wrote:&gt;&gt; Hi,&gt;&gt; (1st post so excuses in advance for the potential newbyness of the&gt;&gt; question)&gt;&gt;&gt;&gt; I'd like to fold a function, i.e. to use the over adverb (/) , for&gt;&gt; each rows of a table.&gt;&gt;&gt;&gt; Here's my try :&gt;&gt; unary_corporate_action:{[x;y] update price:price * ycoef from x >> where>> date < ydate}; / for a&gt;&gt; tbl unary_unary_corporate_action/ corporate_action;&gt;&gt;&gt;&gt; where tbl is a price table, and corporate_action is a table of&gt;&gt; corporate_action&gt;&gt;&gt;&gt; What I'd wanted was to recursively apply the unary function to the&gt;&gt; initial tbl&gt;&gt;&gt;&gt; The result is a 'nyi error message (not yet implemented)&gt;&gt;&gt;&gt; what's the difference wrt a&gt;&gt; 100 {2*x+y}/ 1 2 3&gt;&gt; that works?&gt;&gt; or wrt a&gt;&gt; {(xprice) +1} each tbl>> that also works?>> (well, there are obviously differences, but what particular point>> makes it “nyi”?)>>>> Do I have smarter alternatives than using a for loop?>>>> Many thanks in advance>>>> Julien-- Aaron Daviesaaron.davies@gmail.com</jlau…>