[q-lang-users] lambda
Brought to you by:
agraef
From: Eddie R. <ed...@bm...> - 2006-10-20 19:33:39
|
Me again. When I run the following: // assume X is sorted medianS X = if (#X) mod 2 = 0 then (X!(#X div 2 - 1) + X!(#X div 2))/2 else X!(#X div 2); outliers X = filter (\X. (X < LF) or (X > RF)) X where (LF, RF) = (LQ - IRQ, UQ + IRQ) where IRQ = 1.5 * (UQ - LQ) where UQ = medianS (drop (trunc (#X/2 + 0.5)) L) where LQ = medianS (take (trunc (#X/2)) L) where L = sort (<) X; > outliers $ [1] ++ [20..30] ! Error in conditional the debugger's last line before the "! Error in conditional" 0> stdlib.q, line 134: filter (\[...] . (...) or (...)) [1,20,21,...] ==> [1|filter (...) [...]] if (\[...] . (...) or (...)) 1 When I change the (\X. (X < LF) or (X > RF)) to (\Y. (Y < LF) or (Y > RF)) it works > outliers $ [1] ++ [20..30] => [1] Why should it matter that I'm using X inside of the lambda function? I know that X is a parameter to the outliers equation, but shouldn't lambda's X be private to (\X. (X < LF) or (X > RF))? Eddie P.S. I really don't mean to be such an aggrivation. I really am enjoying Q! |