cancel
Showing results for 
Search instead for 
Did you mean: 

. (dot) Does Not Work with mod?

Flying
New Contributor III
Hi,

I'm facing a strange error with mod and . (dot) operators. Please see the session log below:

===============SESSION=======================
D:\DEV>q
KDB+ 3.2 2015.03.05 Copyright (C) 1993-2015 Kx Systems
w32/ 4()core 4095MB Think flying-thinkpad 192.168.10.112 NONEXPIRE

Welcome to kdb+ 32bit edition
For support please see http://groups.google.com/d/forum/personal-kdbplus
Tutorials can be found at http://code.kx.com/wiki/Tutorials
To exit, type \\
To remove this startup msg, edit q.q
q)mod
k){x-y*x div y}
q)mod . 192 2
'
q).[mod;192 2]
0
q)
===============SESSION=======================

Why is it that mod does not work with . (dot) operator (NOTE: the error message is empty)?
3 REPLIES 3

charlie
New Contributor II
New Contributor II
you need to wrap it in ()

q)(mod). 192 2
0

to make it a noun. Same would for for e.g. +


Flying
New Contributor III
Yes, I figured that out after the original post.

But I'm still curious, though: Is this requirement due to the fact that mod was defined as a k function instead of a q one?

=============TEST=============
q)f:{x-y*x div y}
q)f
{x-y*x div y}
q)f . 1 2
1
q)mod
k){x-y*x div y}
q)mod . 1 2
'
q)(mod). 1 2
1
=============TEST=============

sohagan
New Contributor
this should explain all you need...

https://groups.google.com/forum/#!searchin/personal-kdbplus/parentheses/personal-kdbplus/r60hWq7g8xw/xpALjkMip9IJ
http://www.kx.com/q/d/a/q1.htm#Verbs and Adverbs
http://code.kx.com/wiki/Reference/Grammar

HTH,
Sean