adkins@pound.cis.ohio-state.edu (Brian Adkins) (02/24/91)
Thanks for the responses concerning the APPLY function. I realized the source of my problem is the fact that the function is incorrectly documented in the Quick Reference Guide (I don't have the programmer's reference manual). In the Quick guide it says that level 1 should contain the list of symbols and level 2 should contain the name. This is just the opposite of course. Also, I'm confused about one thing. All of the other multi-parameter functions that I am familiar with are similar in one regard. The order of arguments in the stack version correspond to the order of arguments in the algebraic version as 'function(level n, ... , level 1)' where n is the number of arguments, and level i is the argument that would be at level i in the stack version. APPLY is an exception to this rule, for example: level 2: n x {symb...} level 1: m y 'name' COMB %CH APPLY or or or 'COMB(n, m)' '%CH(x,y)' 'APPLY('name', {symb...})' The guys at HP customer support could not tell me why APPLY differed from the norm in this respect. Any ideas?
jsims@vuse.vanderbilt.edu (J. Robert Sims) (02/25/91)
The apply function takes a variable number of arguments, the others (COMB, %ch) don't. The syntax for apply is not 'APPLY('name', {symb...})' it's 'APPLY(name, symb1, symb2, ...)' name is still at the wrong end of the list, but the function is more logical to understand if the name is at the beginning of the list than the end. Side note: if you use 'APPLY(A,B)' where B is defined as {C D}, and evaluate it, you get a Bad Argument Type error, and { 'A' { C D } } is returned to the stack. It looks like apply is given its arguments in the same order that the command line wants them, but that apply uses something other than ->list when its arguments are taken off the stack to be passed to the main routine. I'll bet that if ->list had a command line equivalent, it would be ->list(size, A, B, ...) to form the list {A B ...} Rob jsims@vuse.vanderbilt.edu
akcs.joehorn@hpcvbbs.UUCP (Joseph K. Horn) (02/26/91)
Brian Adkins asks why APPLY is an exception to the rule that functions have equivalent RPN and algebraic argument orders. So does XROOT. Strange. Matter of fact, so do integral, derivative, and | (the WHERE function). The algebraic argument order is "backwards" for all of these. -- Joseph K. Horn -- Peripheral Vision, Ltd. --