-2
myFunc:{[x]
   // ...
}

I know i can perform a row operation on my table using the update statement this way:

update newVal: myFunc each someField from someTable;

Now if my function takes 2 params:

myFunc2: {[x;y]
   // x and y are different types
}

How do i now pass in two params per row operation? I tried these:

update newVal: myFunc2 each someField, otherField from someTable;
update newVal: myFunc2 . (someField;otherField) from someTable;

Didn't seem to work, what is the right way to pass more than 1 params to a function in an update stmt?

delita
  • 1,571
  • 1
  • 19
  • 25
  • 3
    Similar question can be found here with a good answer https://stackoverflow.com/questions/48338213/q-apply-function-on-table-rowwise – DanDan4561 Oct 03 '18 at 01:34
  • Possible duplicate of [q - apply function on table rowwise](https://stackoverflow.com/questions/48338213/q-apply-function-on-table-rowwise) – nyi Oct 03 '18 at 06:31

2 Answers2

3

You should use each-both adverb ' as in example below

update newVal: myFunc2'[someField;otherField] from someTable
Anton Dovzhenko
  • 2,399
  • 11
  • 16
  • Would this work say if i have a function which takes more than 2 params? If i understand the correctly this means someField myFunc2' otherField.... – delita Oct 03 '18 at 02:35
  • Yes, `'` will work for any number of parameters. Thought `a func' b` construct works only for two, `func'[a;b;c;...]` should be used instead – Anton Dovzhenko Oct 03 '18 at 04:48
0
update {x+y}'[a;b] from ([] a:1 2 3; b:10 20 30)

a b c 1 10 11 2 20 22 3 30 33

Deepak
  • 1
  • 2
  • this answer came in Low Quality posts in SO since its code only answer.... Could you add any commentary to your answer? Explain your logic, and give a little commentary on what your code is intended to do. This will help the OP, but it will also serve as commentary for future users – – Ram Ghadiyaram Mar 23 '19 at 07:00