

jason_fealy
Forum Replies Created
-
jason_fealy
MemberJanuary 11, 2022 at 12:00 am in reply to: Double comma when converting qsql statements to functional statementsThe list of constraints (index 2) is itself a parse tree which means value cannot be applied to the output of parse. For a simple example like this, it’s just a matter of removing a level of nesting but just to illustrate….
q)show t:([]a:1 2;b:10 20); a b ---- 1 10 2 20 q)show pt:parse"select from t where a>1"; // parse tree at index 2 ? `t ,,(>;`a;1) 0b () q)value pt // value cannot be applied 'type [0] value pt // value cannot be applied ^ q)@[pt;2;eval] // evalute the parse tree at index 2 which removes a level of nesting ? `t ,(>;`a;1) 0b () q) q)value @[pt;2;eval] // value can be applied to output a b ---- 2 20 q) q)?[t;enlist(>;`a;1);0b;()] ~ value @[pt;2;eval] // matches manually typed functional form 1b
Some further reading which includes more complex examples https://code.kx.com/q/wp/parse-trees/
-
jason_fealy
MemberJanuary 8, 2022 at 12:00 am in reply to: q console error causes other client connections to hangYes it’s expected as the first process is in debug mode – https://code.kx.com/q/basics/debug/#debugger
However, you don’t need to restart the first process, you can resume or abort execution from the debugger depending on your use case. The sync message from the 2nd process should then be processed.
https://code.kx.com/q/basics/debug/#resumehttps://code.kx.com/q/basics/debug/#abort
-
jason_fealy
MemberJanuary 4, 2022 at 12:00 am in reply to: Accessing previous calculated value from a column in current rowhttps://code.kx.com/q/ref/accumulators/#binary-values
q)select c1,c2:0{(x+10+y)%2}c1 from t c1 c2 ----------- 1 5.5 2 8.75 3 10.875 4 12.4375 5 13.71875 6 14.85938 7 15.92969 8 16.96484 9 17.98242
-
jason_fealy
MemberNovember 10, 2021 at 12:00 am in reply to: Problem with log message when using trapHi, the trap itself needs to be a function otherwise it will be evaluated regardless of whether the application of your function (hclose) fails or not.
https://code.kx.com/q/ref/apply/#when-e-is-not-a-functionq)logError:{-1"Error: ",x;} q)@[10+;10;logError"Can't add"] Error: Can't add 20 q)@[10+;10;{logError"Can't add"}] 20 q)@[10+;`abc;{logError"Can't add"}] Error: Can't add
-
That number cannot be represented exactly as a floating point number i.e. it has a infinitely repeating representation (if you look at the attached pic you’ll see the binary representation is infinite). Therefore, by adjusting display precision, you’ll see different outputs. Some numbers can be represented as a floating point number e.g.
q)P 7 q)1.125 1.126 1.125 1.126 q)P 0 q)1.125 1.126 1.125 1.1259999999999999
https://www.exploringbinary.com/why-0-point-1-does-not-exist-in-floating-point/
-
negating the handle will append the newline
q)-1"hello, world"; hello, world q) q)-1("hello";"world"); hello world