Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
J (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Verbs and Modifiers== A program or routine β something that takes data as input and produces data as output β is called a ''verb''. J has a rich set of predefined verbs, all of which work on multiple data types automatically: for example, the verb {{mono|i.}} searches within arrays of any size to find matches: <syntaxhighlight lang="j"> 3 1 4 1 5 9 i. 3 1 NB. find the index of the first occurrence of 3, and of 1 0 1 3 1 4 1 5 9 i: 3 1 NB. find the index of the last occurrence of 3, and of 1 0 3 </syntaxhighlight> User programs can be named and used wherever primitives are allowed. The power of J comes largely from its ''modifiers'': symbols that take nouns '''and verbs''' as operands and apply the operands in a specified way. For example, the modifier {{mono|/}} takes one operand, a verb to its left, and produces a verb that applies that verb between each item of its argument. That is, {{mono|+/}} is a verb, defined as 'apply {{mono|+}} between the items of your argument' Thus, the sentence <syntaxhighlight lang="j"> +/ 1 2 3 4 5 </syntaxhighlight> produces the effect of <syntaxhighlight lang="j"> 1 + 2 + 3 + 4 + 5 +/ 1 2 3 4 5 15 </syntaxhighlight> J has roughly two dozen of these modifiers. All of them can apply to any verb, even a user-written verb, and users may write their own modifiers. While modifiers are powerful individually, allowing * repeated execution, i. e. ''do-while'' * conditional execution, i. e. ''if'' * execution of regular or irregular subsets of arguments some of the modifiers control the order in which components are executed, allowing modifiers to be combined in any order to produce the unlimited variety of operations needed for practical programming.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)