9 ms·
Wow, super cool design decision! Can you give multiple named variables? How would you write a function like this? const f = (a,b,c) => { return a * b + c
by surprisetalk 4y ago
Wow, super cool design decision!
Can you give multiple named variables? How would you write a function like this?
const f = (a,b,c) => { return a * b + c }
Also, is this just q/kdb, or does this also apply to K?
- maest 4y agoThe default variable names go all the way up to z. So you I would write your function as: f:{z+y*x} (k is evaluated strictly right to left - another design decision that I quite like -, so I had to move the variables around in the expression) If you wish, you can provide your own variable names as follows: f:{[a;b;c]c+b*a} This works in k and q (q is largely k with some nice-to-have functions defined on top).
- leprechaun1066 4y agoK4 is the implementation language of q, kdb is the database part of the language. Most q is just named utility functions written in K4. There isn't really much difference in what the machine does with them under the covers, but when stuck on a problem talking about q is more likely to get help than k. You can provide up to 8 named inputs in a function definition. q example for running sum of 8 inputs: q)f:{[a;b;c;d;e;f;g;h]sums a,b,c,d,e,f,g,h} same in K4: q)\ f:{[a;b;c;d;e;f;g;h]+\a,b,c,d,e,f,g,h}