Content deleted Content added
m v2.05b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation) |
Add section |
||
Line 25:
In particular, such ranges are supported in [[C++20]],<ref>[https://en.cppreference.com/w/cpp/ranges cppreference]</ref> [[Boost C++ Libraries]]<ref>[http://www.boost.org/libs/range/index.html Boost.Range documentation]</ref> and the [[D (programming language)|D]] standard library.<ref>[http://dlang.org/phobos/std_range.html D Phobos Runtime Library std.range module]</ref>
== Range as a data type ==
A data type for ranges can be implemented using [[Generic programming|generics]].
Example in [[C Sharp (programming language)|C#]].
<syntaxhighlight lang="csharp">
public record Range<T>(T Start, T End);
</syntaxhighlight>
Example in [[PHP]].
<syntaxhighlight lang="php">
readonly class Range<T> {
public function __construct(
public T $start,
public T $end,
) {}
}
</syntaxhighlight>
Rust have a built-in range struct in the standard library in {{Mono|std::ops::Range}}.<ref>{{cite web |title=Range in std::ops - Rust |url=https://doc.rust-lang.org/std/ops/struct.Range.html |website=doc.rust-lang.org |access-date=17 October 2024}}</ref>
==See also==
Line 33 ⟶ 53:
{{DEFAULTSORT:Range (Computer Science)}}
[[Category:
[[Category:Articles with example PHP code]]
[[Category:Arrays]]
[[Category:Programming constructs]]
|