Comparison of programming languages (basic instructions): Difference between revisions

Content deleted Content added
Add more code tags
More code tags added
Tag: nowiki added
Line 1,365:
|-
| [[Ada (programming language)|Ada]]<ref name="Ada_RM_2012" />
| <code>'''type''' name '''is''' «'''abstract'''» «'''tagged'''» «'''limited'''» ['''record'''{{indent|2}}field{{sub|1}} ''':''' type''';'''{{indent|2}}field{{sub|2}} ''':''' type''';'''{{indent|2}}...<br />'''end record''' <nowiki>|</nowiki> '''null record''']</code>
|
'''type''' name '''is''' «'''abstract'''» «'''tagged'''» «'''limited'''» ['''record'''
field{{sub|1}} ''':''' type''';'''
field{{sub|2}} ''':''' type''';'''
...
'''end record''' {{!}} '''null record''']
| {{n/a}}
| Any combination of records, unions, and enumerations (as well as references to those, enabling recursive types).
Line 1,797 ⟶ 1,792:
|- valign="top"
| [[Ada (programming language)|Ada]]<ref name="Ada_RM_2012" />
| <code>'''if''' condition '''then'''{{indent|2}}statements<br />«'''else'''{{indent|2}}statements»<br />'''end if'''</code>
|
'''if''' condition '''then'''
statements
«'''else'''
statements»
'''end if'''
|
'''if''' condition{{sub|1}} '''then'''
Line 1,837 ⟶ 1,827:
|- valign="top"
| [[Seed7]]
| <code>'''if''' condition '''then'''{{indent|2}}statements<br />«'''else'''{{indent|2}}statements»<br />'''end if'''</code>
|
'''if''' condition '''then'''
statements
«'''else'''
statements»
'''end if'''
|
'''if''' condition{{sub|1}} '''then'''
Line 1,852 ⟶ 1,837:
statements»
'''end if'''
| <code>'''case''' expression '''of'''{{indent|2}}'''when''' set1 ''':''' statements{{indent|2}}...{{indent|2}}«'''otherwise:''' statements»<br />'''end case'''</code>
|
'''case''' expression '''of'''
'''when''' set1 ''':''' statements
...
«'''otherwise:''' statements»
'''end case'''
|
|- valign="top"
| [[Modula-2]]
| <code>'''if''' condition '''then'''{{indent|2}}statements<br />«'''else'''{{indent|2}}statements»<br />'''end'''</code>
|
'''if''' condition '''then'''
statements
«'''else'''
statements»
'''end'''
|
'''if''' condition{{sub|1}} '''then'''
Line 1,876 ⟶ 1,851:
statements»
'''end'''
| rowspan=1 | <code>'''case''' expression '''of'''{{indent|2}}caseLabelList ''':''' statements '''<nowiki>|</nowiki>'''{{indent|2}}...{{indent|2}}«'''else''' statements»<br />'''end'''</code>
| rowspan=1 |
'''case''' expression '''of'''
caseLabelList ''':''' statements '''{{!}}'''
...
«'''else''' statements»
'''end'''
|
|- valign="top"
Line 1,897 ⟶ 1,867:
|- valign="top"
| [[APL (programming language)|APL]]
| <code>''':If''' condition{{indent|2}}instructions<br />«''':Else'''{{indent|2}}instructions»<br />''':EndIf'''</code>
|
''':If''' condition
instructions
«''':Else'''
instructions»
''':EndIf'''
|
''':If''' condition
Line 1,939 ⟶ 1,904:
'''if ('''condition''')''' instructions
'''else { if ('''condition''')''' instructions '''}'''
| <code>'''switch ('''variable''') {'''{{indent|2}}'''case''' case1''':''' instructions «; '''break;'''»{{indent|2}}...{{indent|2}}«'''default:''' instructions»<br />'''}'''</code>
|
'''switch ('''variable''') {'''
'''case''' case1''':''' instructions «; '''break;'''»
...
«'''default:''' instructions»
'''}'''
| <code>condition '''[[?:|?]]''' valueIfTrue '''[[?:|:]]''' valueIfFalse</code>
|- valign="top"
Line 1,991 ⟶ 1,951:
«'''default:''' instructions»
'''}'''
| <code>'''switch '''variable''' {'''{{indent|2}}'''case''' case1''':''' instructions{{indent|2}}...{{indent|2}}«'''default:''' instructions»<br />'''}'''</code>
|
'''switch '''variable''' {'''
'''case''' case1''':''' instructions
...
«'''default:''' instructions»
'''}'''
|
|- valign="top"
Line 2,006 ⟶ 1,961:
...
«'''else {'''instructions'''}'''»
| <code>'''switch '''variable''' {'''{{indent|2}}'''case''' case1''':''' instructions{{indent|2}}...{{indent|2}}«'''default:''' instructions»<br />'''}'''</code>
|
'''switch '''variable''' {'''
'''case''' case1''':''' instructions
...
«'''default:''' instructions»
'''}'''
|
|- valign="top"
Line 2,045 ⟶ 1,995:
...
«'''else {'''instructions'''}'''
| <code>'''given''' variable '''{'''{{indent|2}}'''when''' case1 '''{ '''instructions''' }'''{{indent|2}}...{{indent|2}}«'''default { '''instructions''' }'''»<br />'''}'''</code>
|
'''given''' variable '''{'''
'''when''' case1 '''{ '''instructions''' }'''
...
«'''default { '''instructions''' }'''»
'''}'''
| <code>condition '''[[?:|??]]''' valueIfTrue '''!!''' valueIfFalse</code>
|- valign="top"
Line 2,095 ⟶ 2,040:
|- valign="top"
| Smalltalk
| <code>condition '''ifTrue:'''{{indent|2}}trueBlock<br />«'''ifFalse:'''{{indent|2}}falseBlock»<br />'''end'''</code>
|
condition '''ifTrue:'''
trueBlock
«'''ifFalse:'''
falseBlock»
'''end'''
|
|
Line 2,166 ⟶ 2,106:
instructions
'''end'''»{{ref|pascal semicolon|[c]}}
| <code>'''case '''variable''' of'''{{indent|2}}case1''':''' instructions{{indent|2}}...{{indent|2}}«'''else:''' instructions»<br />'''end'''</code>{{ref|pascal semicolon|[c]}}
|
'''case '''variable''' of'''
case1''':''' instructions
...
«'''else:''' instructions»
'''end'''{{ref|pascal semicolon|[c]}}
|- valign="top"
| Visual Basic
Line 2,239 ⟶ 2,174:
|- valign="top"
| Fortran
| <code>'''IF ('''condition''') THEN'''{{indent|2}}instructions<br />'''ELSE'''{{indent|2}}instructions<br />'''ENDIF'''</code>
|
'''IF ('''condition''') THEN'''
instructions
'''ELSE'''
instructions
'''ENDIF'''
|
'''IF ('''condition''') THEN '''
Line 2,338 ⟶ 2,268:
|- valign="top"
| Bash shell
| <code>'''if''' condition-command; '''then'''{{indent|2}}expression<br />«'''else'''{{indent|2}}expression»<br />'''fi'''</code>
|
'''if''' condition-command; '''then'''
expression
«'''else'''
expression»
'''fi'''
|
'''if''' condition-command; '''then'''
Line 2,417 ⟶ 2,342:
|- valign="top"
| Rust
| <code>'''if''' condition '''{'''{{indent|2}}expression<br />'''}« else {'''{{indent|2}}expression<br />'''}'''»</code>
|
'''if''' condition '''{'''
expression
'''}« else {'''
expression
'''}'''»
|
'''if''' condition '''{'''