cancel
Showing results for 
Search instead for 
Did you mean: 

What do 1@ and 2@ do?

ag1
New Contributor
q)x:"3B"
q
)e:(-1#x)[0]
q
)e
"B"
q
)0@e
'B
  [0]  0@e
        ^
q)1@e
B1
q)2@e
B2
q)3@e
'
Cannot write to handle 3. OS reports: Invalid argument
 
[0]  3@e
       
^

is 1@e calling binary save? http://code.kx.com/wiki/Reference/OneColon
is 2@e calling dynamic load? http://code.kx.com/wiki/Reference/TwoColon

There were no B1 or B2 files written... what happened?
2 REPLIES 2

quintanar401
New Contributor
1 pints a msg to stdout, 2 to stderr. 1 and 2 after B is the return value printed by q) cmd line.

среда, 21 июня 2017 г., 10:29:21 UTC+3 пользователь ag написал:
q)x:"3B"
q
)e:(-1#x)[0]
q
)e
"B"
q
)0@e
'B
  [0]  0@e
        ^
q)1@e
B1
q)2@e
B2
q)3@e
'
Cannot write to handle 3. OS reports: Invalid argument
 
[0]  3@e
       
^

is 1@e calling binary save? http://code.kx.com/wiki/Reference/OneColon
is 2@e calling dynamic load? http://code.kx.com/wiki/Reference/TwoColon

There were no B1 or B2 files written... what happened?

jim1
New Contributor
1 is the file-handle for stdout, 2 is the file-handle for stderr. @ is applying the functions 1 and 2 using the argument you provided, e. See here for more info: http://code.kx.com/wiki/Reference/AtSymbol 
"A monadic function g with argument d can be evaluated by g@d or g . enlist d."

So you are simply printing the value of the variable e to stdout and stderr. 3@e fails because you don't have an file open with fd=3.