I want to compute a binomial coefficient for a program I am working on for helping poker players during play and noticed that a factorial function is not built into the Q language and would have thought that "!" would have been overloaded to support factorials so I decided to write my own one:
.q.fctrl:{prd 1+til x}
Voila; now you have a factorial function that takes a scalar and computes its factorial
q)fctrl 5
120
Wednesday, 20 July 2011
Monday, 11 July 2011
IPC Port Handles
A word to the wise about the scope of a IPC handle variable. Put the handle always as a local variable as putting it as a global scoped variable is dangerous. If the underlying remote Q process is bounced then the handler will not rebind to the new process making it dead! Be wary of putting it is a global variable, catching the exception and rebinding yourself as this is a premature optimization.
Subscribe to:
Comments (Atom)