What is a range - a structured type in ruby, Data Structure & Algorithms

Assignment Help:

Range: A Structured Type in Ruby

Ruby has a numerous structured types, comprising arrays, hashes, sets, classes, streams, and ranges. In this section we would only discuss ranges briefly as an instance of a structured type.

Range of T ADT signifies a set of values of type T (called the base type) between two extremes. Start value is a value of type T which sets the lower bound of a range, and end value is a value of type T which sets the upper bound of a range. Range itself is the set of values of type T between lower and upper bounds. For illustration, Range of Integers from 1 to 10 inclusive is the set of values {1, 2, 3, ..., 10}.

A range can be inclusive, meaning that it includes end value, or exclusive, meaning that it doesn't include the end value. Inclusive ranges are written with two dots between extremes, and exclusive ranges with three dots. Hence Range of Integers from 1 to 10 inclusive is written 1...10, and Range of Integers from 1 to 10 exclusive (the set {1, 2, 3, ..., 9}), is written 1...10.

A type can be a range base type only if it supports order comparisons. For instance, Integer, Real, and String types support order comparisons and so may be range base types however Sets and Arrays don't, so they can't be range base types.

 


Related Discussions:- What is a range - a structured type in ruby

Determine yiq colour model, Determine YIQ Colour Model Whereas an RGB m...

Determine YIQ Colour Model Whereas an RGB monitor requires separate signals for the red, green, and blue components of an image, a television monitor uses a single composite si

Indexed sequential files, Indexed Sequential Files An index is inserted...

Indexed Sequential Files An index is inserted to the sequential file to provide random access. An overflow area required to be maintained to permit insertion in sequence. I

Row major representation, Row Major Representation In memory the primar...

Row Major Representation In memory the primary method of representing two-dimensional array is the row major representation. Under this representation, the primary row of the a

What are the objectives of visual realism applications, What are the Object...

What are the Objectives of visual realism applications After studying this unit, you should be able to know specific needs of realism, add realism to pictures by el

Create algorithm for similarities between documents, Here is a diagram show...

Here is a diagram showing similarities between documents; this is an actual set of physics lab assignments from a large university. Each node (square) in the graph is a doc

#, if two relations R and S are joined, then the non matching tuples of bot...

if two relations R and S are joined, then the non matching tuples of both R and S are ignored in

Conversion of general trees to binary trees, Taking a suitable example expl...

Taking a suitable example explains how a general tree can be shown as a Binary Tree. Conversion of general trees to binary trees: A general tree can be changed into an equiv

Hasing and indexing, differentiate between indexing and hashing in file org...

differentiate between indexing and hashing in file organization

Array, extra key inserted at end of array is called

extra key inserted at end of array is called

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd