Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.6K Views
|
2 Replies
|
1 Total Like
View groups...
Share
Share this post:

Weird 3-blanks argument in defining function

Posted 3 years ago

Consider defining such a function with blanks arguments

f\[x BlankBlank,  y BlankBlank, z BlankBlankBlank\] := x + y - z

not that the third arguments with 3 blanks ("x" or "y" follows two blanks). When input three actual parameters, the function is normal. But when input 4 actual parameters, the results are stranger: when z serves as an empty, it seems obtain a value -1!

Input\[1\]: f\[100, 1, 2, 3\],
Output\[3\]: 95.

To know the details, I get all the possible permutation distributing the actual parameters

Input\[2\]:ReplaceList
Output\[2\]:{95, 100, 105, 100, 105, 105}

which, for easy seeing the detail, corresponds to the following:

Input\[3\]ReplaceList\[f\[100, 1, 2, 3\], 
  f-> f\[x\] + f\[y\] - f\[z\]\] // TableForm;

Output[3] shows that when f[z] serves as f[], it get 1. but if the function was revised as x+y+z, when f[z] serves as f[], it would get 0. Why do -f[] get 1 and f[] get 0? See the program.nb attached.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use