Guides/Language FAQ/Tacit Train

From J Wiki
Jump to navigation Jump to search

Why does "+/ % # 1 2 3" give me 0.333333 instead of the mean, 2?

You want +/ % # to be treated as a "fork", a 3-element sequence of verbs (called a train of verbs). Often that train is defined and named as follows.

   mean =: +/ % #
   mean 1 2 3
2

To be recognized as a fork, the train of verbs must be isolated from surrounding elements in a way that the J sentence parser recognizes. Parentheses around the fork or other verb train is another way to isolate the train, as shown next.

   (+/ % #) 1 2 3
2

See also the next question.

See Also


Contributed by Your Name