Call a function: Difference between revisions

Content added Content deleted
(J: clarification about empty arrays)
Line 129: Line 129:


''A function that requires no arguments'' can be simulated by calling a function with empty argument list: <lang j>f''</lang> Note that an empty list of characters is the only constant in the language which is an empty list. That said, most operations in the language do not care what type of data is not present, in an array which contains nothing.
''A function that requires no arguments'' can be simulated by calling a function with empty argument list: <lang j>f''</lang> Note that an empty list of characters is the only constant in the language which is an empty list. That said, most operations in the language do not care what type of data is not present, in an array which contains nothing.



''A function with a fixed number of arguments'' gets special treatment in J when the fixed number is 1 or 2. <lang j>f 'one argument'</lang>and <lang j>'this example has two arguments' f 'the other argument'</lang> Alternatively, the function can be written such that an argument list is an error when it's the wrong length.
''A function with a fixed number of arguments'' gets special treatment in J when the fixed number is 1 or 2. <lang j>f 'one argument'</lang>and <lang j>'this example has two arguments' f 'the other argument'</lang> Alternatively, the function can be written such that an argument list is an error when it's the wrong length.