Content deleted Content added
Salix alba (talk | contribs) →Range as a operator: Perl |
mNo edit summary |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 36:
Example in [[Kotlin (programming language)|Kotlin]].
<syntaxhighlight lang="
data class Range<T: Comparable<T>>(val start: T, val end: T)
</syntaxhighlight>
Line 79:
As does [[C Sharp (programming language)|C#]],<ref>{{cite web|last1=BillWagner|access-date=2025-02-22|title=Explore ranges of data using indices and ranges - C#|url=https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/ranges-indexes|date=14 November 2023|website=learn.microsoft.com}}</ref>
<syntaxhighlight lang="
string items[] = ["one","two","three","four"];
string first_three_items[] = items[0..2];
</syntaxhighlight>
[[F Sharp (programming_language)|F#]],<ref>{{cite web|access-date=2025-02-22|title=Range Operator|url=https://camilotk.github.io/fsharp-by-example/chapters/range-operator/|date=17 February 2023|website=F# by example}}</ref>
<syntaxhighlight lang="
[1..4]
// Outputs: [1; 2; 3; 4]
</syntaxhighlight>
[[Kotlin (programming language)|Kotlin]],<ref>{{cite web|access-date=2025-02-22|title=Ranges and progressions - Kotlin|url=https://kotlinlang.org/docs/ranges.html#progression|website=Kotlin Help}}</ref>
<syntaxhighlight lang="
for (i in 1..5) print(i)
</syntaxhighlight>
and [[Perl]].<ref>{{cite web|access-date=2025-02-22|title=perlop - Perl expressions: operators, precedence, string literals - Perldoc Browser|url=https://perldoc.perl.org/perlop#Range-Operators|website=perldoc.perl.org}}</ref>
<syntaxhighlight lang="
for
</syntaxhighlight>
|