Range (computer programming)

A range represents a list of values between its first and last. The lower limit is the first value and the upper limit is the last value. The range between 1 and 6 is 2, 3, 4, and 5.

Range may refer to: values in a variable or array, an operator, a data type, or to be used instead of an iterator.

Examples

Below are some notable languages using the range operator (..):

C#,[1] <syntaxhighlight lang="C#"> string items[] = ["one","two","three","four"]; string first_three_items[] = items[0..2]; </syntaxhighlight> F#,[2] <syntaxhighlight lang="F#"> [1..6] </syntaxhighlight> Perl,[3] <syntaxhighlight lang="Perl"> for(1..6) { print } </syntaxhighlight> Kotlin,[4] <syntaxhighlight lang="Kotlin"> for (i in 1..6) print(i) </syntaxhighlight> V (Vlang)[5] <syntaxhighlight lang="carbon"> for i in 1..6 { print(i) } </syntaxhighlight>

Range (computer Programming) Media

References

  1. BillWagner (14 November 2023). "Explore ranges of data using indices and ranges - C#". learn.microsoft.com. Retrieved 2025-02-22.
  2. "Range Operator". F# by example. 17 February 2023. Retrieved 2025-02-22.
  3. "perlop - Perl expressions: operators, precedence, string literals - Perldoc Browser". perldoc.perl.org. Retrieved 2025-02-22.
  4. "Ranges and progressions - Kotlin". Kotlin Help. Retrieved 2025-02-22.
  5. Trex, Nova (24 December 2024). V Programming: Building Robust and Efficient Software Systems. pp. 87–88. ASIN B0DRJMP1HM. ISBN 979-8304813778.