You don't really mean that. ;) A function is a relationship between argument and result where there's each argument has exactly one result. So a function of no arguments would have no result. Or, if we are being generous, we could declare that it has a constant argument (and, thus, a constant result). So that would be a constant.
What you are asking for, I think, actually, is a procedure which produces different results at different times based on whatever obscure variables or whatever it depends on. (And your example of a random number generation process sort of illustrates that concept.) (But when used in a tacit definition, you can just use your randdie as is - it will ignore its arguments so put it where ever that fits.) Anyways... the technical answer is "no". The practical answer is "but that should not matter" and the obscure answer is that you can map a variable to a file if you really want to extend the reach of your system (but that has all sorts of implications which you probably were not looking for, so let's stick with the other two answers?) Anyways, I hope this helps (but it probably doesn't...). Thanks, -- Raul On Sun, Nov 26, 2017 at 12:42 PM, Andrew Dabrowski <[email protected]> wrote: > Is it possible to define a nullary function in J? In other languages > they're sometimes convenient, for example a function that returns a random > element. It's a bit awkward to have to use a dummy argument, like > > randdie =: 1 + ? @: 6: > > which must be called like > > randdie 0 > > and when used in a tacit definition must be called like > > randdie ]. > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
