Editing
Diamond
From NARS2000
Jump to navigation
Jump to search
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!
__NOTOC__ {{Article header |sym={diamond} |def=Statement separator |ks=ALT+` (Accent grave) |char=8900 or x22C4 |kb=[[File:APLKB-Diamond.png]]}} ==Usage== While the diamond operator ('''<big><big>{diamond}</big></big>''') can be used in an immediate statement to the Session Manager, it is most commonly used in a [[functions|function]] to start a new statement '''on the same''' physical line-row of user-code. It is used similarly to the semi colon ('''<big>;</big>''') in C, Pascal, PHP and many other languages, or the colon ('''<big>:</big>''') and backslash ('''<big>\</big>''') in some versions of Basic. It allows another statement to be concisely set on the same line. '''Note:''' The '''<big><big>{diamond}</big></big>''' operator <u>cannot</u> be used after a [[lamp]] (<big><big>{lamp}</big></big>) comment operator appears on the same line, as all characters after <big><big>{lamp}</big></big> are ignored. '''Also note''' the '''<big><big>{diamond}</big></big>''' operator represents an <u>exception to the rule</u> that APL's interpreter executes from right to left, since the ''leftmost APL statement'' is executed BEFORE the adjacent APL statement after the next '''<big><big>{diamond}</big></big>''' operator and so on. Each APL statement is executed sequentially '''as if''' listed on multiple lines. The '''<big><big>{diamond}</big></big>''' operator also helps ''condense'' APL code since fewer ''visual'' lines will contain the same amount of APL coding - and in many instances it ''can result'' in cleaner, or easier-to-read-and-understand APL code. ==Examples== In the first example, the variable K is tested to see if it is greater than or equal to 1. If the test fails, k is set to 1.<br/> :<code><big>{goto}(k{ge}1)/Xr {diamond} K{:=}1<br/>Xr: ⍝This branch/goto Label is deliberately placed <u>first</u> on its own line!</big></code><br/> It is the same as :<code><big>{goto}(k{ge}1)/Xr <br/> K{:=}1<br/>Xr:</big></code><br/> The following represents more <u>condensed</u> ''':for ... :endfor''' control structure in a user-function than if it were shown in four separate lines:<br><font color=purple><strong> <code> A←1 3 5 7 ⋄ :for ii :in ⍳⍴A ⋄ A[ii]←A[ii]*2 ⋄ :endfor ⍝Easier to maintain code if segmented well, esp. when surrounded by long code blocks. </code></strong></font> {{Article footer}} {{Symbol footer|11|D}}
Summary:
Please note that all contributions to NARS2000 may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
NARS2000:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Article footer
(
edit
)
Template:Article header
(
edit
)
Template:Keyboard
(
edit
)
Template:Language Toolbar
(
edit
)
Template:Language Toolbar Group 1
(
edit
)
Template:Language Toolbar Group 10
(
edit
)
Template:Language Toolbar Group 11
(
edit
)
Template:Language Toolbar Group 12
(
edit
)
Template:Language Toolbar Group 2
(
edit
)
Template:Language Toolbar Group 3
(
edit
)
Template:Language Toolbar Group 4
(
edit
)
Template:Language Toolbar Group 5
(
edit
)
Template:Language Toolbar Group 6
(
edit
)
Template:Language Toolbar Group 7
(
edit
)
Template:Language Toolbar Group 8
(
edit
)
Template:Language Toolbar Group 9
(
edit
)
Template:Language Toolbar Notation
(
edit
)
Template:Symbol footer
(
edit
)
Navigation menu
Page actions
Page
Discussion
Read
Edit
Edit source
History
Page actions
Page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Tools
What links here
Related changes
Special pages
Page information