Content deleted Content added
Zoriactrix (talk | contribs) →Slicing: Added notation for slicing a sequence table in Lua 5.3+ |
m a) Move Julia, and change to "yes, also array of array", "yes" alone seems not correct (is it ever? or does the rest have some meaning I missed?). b) Changed color for AWK, was likely wrong, otherwise unclear what it meant. |
||
Line 22:
| {{Mono|''name''<nowiki>'</nowiki>Length}} || {{Mono|''name''<nowiki>'</nowiki>First}} || {{Mono|''name''<nowiki>'</nowiki>Last}}
|-
| [[ALGOL 68]]
| {{Mono|UPB ''name'' - LWB ''name''+1}} <br/>{{Mono|2 UPB ''name'' - 2 LWB ''name''+1}} <br/> etc.|| {{Mono|LWB ''name''}} <br/>{{Mono|2 LWB ''name''}} <br/> etc.|| {{Mono|UPB ''name''}} <br/>
{{Mono|2 UPB ''name''}} <br/> etc.
|-
| [[APL (programming language)|APL]]
| {{Mono|⍴ ''name'' <br/> (⍴ ''name'')[''index'']}} || {{Mono|⎕IO}} || {{Mono|(⍴ ''name'')-~⎕IO <br/> (⍴ ''name'')[''index'']-~⎕IO}}
|-
| [[AWK]]
| {{Mono|''length''}} || {{Mono|1}} || {{Mono|''asorti''}}
|-
Line 36:
|-
| [[CFML]]
| {{Mono|arrayLen(''name'')}} <br/> {{Mono|''name''.len()}} || {{Mono|1}} || {{Mono|''name''.len()}}
|-
| [[Ch (computer programming)|Ch]]
Line 44:
| {{Mono|(length ''name'')}} || {{Mono|0}} || {{Mono|(1- (length ''name''))}}
|-
| [[D (programming language)|D]]
| {{Mono|''name''.length}} || {{Mono|0}} || {{Mono|''name''.length-1}} <br> {{Mono|$-1}}
|-
Line 62:
| {{Mono|*''name''}} || {{Mono|1}} || {{Mono|*''name''}}
|-
| [[Cobra (programming language)|Cobra]], [[D (programming language)|D]], [[Haxe]], [[Java (programming language)|Java]], [[JavaScript]], [[Scala (programming language)|Scala]]
| {{Mono|''name''.length}} || {{Mono|0}} || {{Mono|''name''.length - 1}}
|-
Line 69:
|-
| [[Julia (programming language)|Julia]]
| {{Mono|length(''name'')<br/>size(''name'')}} || {{Mono|
|-
| [[Lingo (programming language)|Lingo]]
Line 81:
|-
| [[Mathematica]]
| {{Mono|Length[''name'']}} || {{Mono|1}} <br/> {{Mono|First[''name'']}} || {{Mono|-1}} <br/> {{Mono|Last[''name'']}}
|-
| [[MATLAB]], [[GNU Octave]]
| {{Mono|length(''name'')}} || {{Mono|1}} || {{Mono|end}}
|-:
| [[Nim (programming language)|Nim]]
| {{Mono|''name''.len}} || {{Mono|''name''.low}}<ref name="nim-lang.org">{{Cite web|url=https://nim-lang.org/docs/tut1.html#advanced-types-arrays|title=Nim Tutorial (Part I)}}</ref> || {{Mono|''name''.high}}
|-
| [[Oberon (programming language)|Oberon]]
| {{Mono|LEN(''name'')}} || {{Mono|0}} || {{Mono|LEN(''name'') - 1}}
|-
| [[Object Pascal]]
| {{Mono|Length(''name'')}} || {{Mono|0}}<br/>{{Mono|low(''name'')}} || {{Mono|Length(''name'')-1}}<br/>{{Mono|high(''name'')}}
|-
| [[Objective-C]] (<code>NSArray *</code> only)
Line 117:
|-
| [[Red (programming language)|Red]]
| {{Mono|length? ''name''}} || {{Mono|''name''/1}} <br/>{{Mono|first ''name''}} || {{Mono|last ''name''}}
|-
| [[Ruby (programming language)|Ruby]]
Line 134:
| {{Mono|''name'' size}} || {{Mono|1}} <br/>{{Mono|''name'' first}} || {{Mono|''name'' size}} <br/>{{Mono|''name'' last}}
|-
| [[Swift (programming language)|Swift]]
| {{Mono|''name.''count}}
| {{Mono|0}}
| {{Mono|''name.''count - 1}}
|-
| [[Unicon (programming language)|Unicon]]
| {{Mono|*''name''}} || {{Mono|1}} || {{Mono|*''name''}}
|-
| [[Visual Basic]]
| {{Mono|UBound(''name'')-LBound(''name'')+1}} || {{Mono|LBound(''name'')}} || {{Mono|UBound(''name'')}}
|-
| [[Wolfram Language]]
| {{Mono|Length[''name'']}} || {{Mono|1}} <br/> {{Mono|First[''name'']}} || {{Mono|-1}} <br/> {{Mono|Last[''name'']}}
|-
| [[Xojo]]
| {{Mono|UBound(''name'')}} || {{Mono|0}} || {{Mono|UBound(''name'')}}
|-
| [[XPath]]/[[XQuery]]
| {{Mono|count($''name'')}} || {{Mono|1}} || {{Mono|count($''name'')}} <br/>{{Mono|last()}}<br/>{{Mono|array:size(''name'')}}<ref name="xpath"/>
Line 166:
|-
| {{Mono|name'''['''index''']''' or name'''['''index<sub>1</sub>''',''' index<sub>2</sub>''']''' etc.}}
| [[ALGOL 58]], [[ALGOL 60]], [[ALGOL 68]], [[AWK]], [[Julia (programming language)|Julia]], [[Modula]], [[Pascal (programming language)|Pascal]], [[Object Pascal]], [[C Sharp (programming language)|C#]], [[S-Lang (programming library)|S-Lang]]<ref name="indexing"/>
|-
| {{Mono|name'''['''index''']''' or name'''['''index<sub>1</sub>''';''' index<sub>2</sub>''']''' etc.<br>or index'''⌷'''name or index<sub>1</sub> index<sub>2</sub>'''⌷'''name etc.}}
Line 172:
|-
| {{Mono|name'''['''index''']'''}}
| [[ActionScript]], [[C (programming language)|C]], [[CFML]], [[Ch (computer programming)|Ch]], [[Cobra (programming language)|Cobra]], [[C++]], [[D (programming language)|D]], [[Go (programming language)|Go]], [[Haxe]], [[Java (programming language)|Java]], [[JavaScript
|-
| {{Mono|'''$'''name'''['''index''']'''}}
Line 231:
In the following table:
*{{Mono|first}}
*{{Mono|last}}
*{{Mono|end}}
*{{Mono|len}}
*{{Mono|step}}
{| class="wikitable"
Line 251:
| [[Python (programming language)|Python]]<ref name="s2"/><ref name="s4"/>
|-
| {{Mono|name'''['''first''':'''end''']'''}}
| [[Go (programming language)|Go]]
|-
| {{Mono|name'''['''first'''..'''last''']'''}}
Line 323:
| [[Cobra (programming language)|Cobra]]
|-
| <code>table.move(name, first, last, 1, {})</code>
| [[Lua (programming language)|Lua]]<ref>{{Cite web |title=Lua 5.3 Reference Manual |url=https://www.lua.org/manual/5.3/manual.html#pdf-table.move |access-date=2022-04-02 |website=www.lua.org}}</ref>
|}
Line 368:
|-
| [[AWK]]
| style="background:
| style="background:honeydew;" | yes, implicitly
| style="background:seashell;" | no
Line 578:
| style="background:honeydew;" | yes
| style="background:honeydew;" | yes
| style="background:honeydew;" | checked <small>(can be skipped locally; or globally by user)</small>
| style="background:honeydew;" | yes, also array of array
| style="background:honeydew;" | yes
| style="background:honeydew;" | yes
|-
| [[Lingo (programming language)|Lingo]]
| style="background:azure;" | 1
| style="background:grey80;" | ?
Line 988:
<ref name="s6">{{cite web |title=Ranges - C# 8.0 language proposals |url=https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/ranges |website=Microsoft Docs |publisher=Microsoft |accessdate=29 August 2019}}</ref>
<ref name="cr1">Size can only be chosen on initialization after which it is fixed.</ref>
<ref name="cr2">Allows arrays of arrays which can be used to emulate most—but not all—aspects multi-dimensional arrays</ref>
<ref name="cr3">Size can only be chosen on initialization when memory is allocated on the heap, as distinguished from when it is allocated on the stack. This note need not be made for a language that always allocates arrays on the heap.</ref>
<ref name="cr4">C99 allows for variable size arrays; however there is almost no compiler available to support this new feature</ref>
<ref name="cr5">This list is strictly comparing language features. In every language (even assembler) it is possible to provide improved array handling via add on libraries. This language has improved array handling as part of its standard library</ref>
<ref name="cr6">The class Array is fixed-size, but OrderedCollection is dynamic</ref>
<ref name="cr7">The indexing base can be 0 or 1 as per the System Variable {{Mono|⎕IO}}. This value may apply to the whole "workspace", or be localized to a user-defined function or a single primitive function by use of the Variant operator ({{Mono|⍠}}).</ref>
<ref name="cr8">At least 2 dimensions (scalar numbers are 1×1 arrays, vectors are 1×n or n×1 arrays).</ref>
<ref name="cr9">Allows creating fixed-size arrays in "unsafe" code, allowing enhanced [[interoperability]] with other language</ref>
<ref name="cr10">Varies by implementation. Newer implementations (FreePascal, Object Pascal (Delphi)) allow heap-based dynamic arrays.</ref>
<ref name="cr11">Behaviour can be tuned via compiler switches. As in DMD 1.0 bounds are checked in debug mode and unchecked in release mode for efficiency</ref>
<ref name="cr12">Almost all Fortran implementations offer bounds checking options via compiler switches. However by default, bounds checking is usually turned off for efficiency</ref>
Line 1,005:
<ref name="cr16">The index type can be a freely chosen [[integer (computer science)|integer type]], [[enumerated type]], or [[character (computing)|character type]]. For arrays with non-compact index types see: [[Associative array]]</ref>
<ref name="cr17">The default base index is the lowest value of the index type used</ref>
<ref name="cr18">Standard [[Perl]] array data types do not support vectorized operations as defined here. However, the [[Perl Data Language]] extension adds array objects with this ability.</ref>
<ref name="cr19">The standard [[Python (programming language)|Python]] array type, <code>list</code>, does not support vectorized operations as defined here. However, the [[numpy]] extension adds array objects with this ability</ref>
<ref name="cr20">By specifying a base index, arrays at an arbitrary base can be created. However, by default, Lua's length operator does not consider the base index of the array when calculating the length. This behavior can be changed via metamethods.</ref>
<ref name="cr21">FreeBASIC supports both variable array lengths and fixed length arrays. Arrays declared with no index range are created as variable-length arrays, while arrays with a declared range are created as fixed-length arrays</ref>
<ref name="cr22">In these languages, one can access or write to an array index greater than or equal to the length of the array, and the array will implicitly grow to that size. This may appear at first as if the bounds are not checked; however, the bounds are checked in order to decide to grow the array, and you do not have unsafe memory access like you do in C.</ref>
<ref name="cr23">PHP's "arrays" are associative arrays. You can use integers and strings as the keys (indexes); floats can also be used as the key but are truncated to integers. There is not really any "base index" or "bounds"</ref>
<ref name="cr24">Haskell arrays (Data.Array) allow using any type which is an instance of Ix as index type. So a custom type can be defined and used as an index type as long as it instances Ix. Also, tuples of Ix types are also Ix types; this is commonly used to implement multi-dimensional arrays</ref>
<ref name="cr25">ALGOL 68 arrays must be subscripted (and sliced) by type {{Mono|INT}}. However a hash function could be used to convert other types to {{Mono|INT}}. e.g. {{Mono|name'''['''hash("string")''']'''}}</ref>
<ref name="cr26">Because C does not bound-check indices, a pointer to the interior of any array can be defined that will symbolically act as a pseudo-array that accommodates negative indices or any integer index origin.</ref>
<ref name="cr27">COBOL arrays may be indexed with "INDEX" types, distinct from integer types</ref>
<ref name="cr28">While COBOL only has arrays-of-arrays, array elements can be accessed with a multi-dimensional-array-like syntax, where the language automatically matches the indexes to the arrays enclosing the item being referenced</ref>
|