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

Write about enterprise manager, Question 1 . Give the structure of PL/SQL B...

Question 1 . Give the structure of PL/SQL Blocks and explain Question 2 . Differentiate between PL/SQL functions and procedures Question 3 . Explain the following Par

Algorithm, Example of worse case of time

Example of worse case of time

Procedure to delete all terminal nodes of the tree, Q. Let a binary tree 'T...

Q. Let a binary tree 'T' be in memory. Write a procedure to delete all terminal nodes of the tree.       A n s . fun ction to Delete Terminal Nodes from Binary Tree

Number of leaf nodes in a complete binary tree, The number of leaf nodes in...

The number of leaf nodes in a complete binary tree of depth d is    2 d

Relative and direct files, Each data record contains a fixed place in a rel...

Each data record contains a fixed place in a relative file. Each record ought to have associated with it in integer key value which will help identify this slot. Therefore, this ke

Algorithm to insert element to a max-heap sequentially, Q. Write  down the ...

Q. Write  down the  algorithm  to  insert  an  element  to  a  max-heap  which  is  represented sequentially.           Ans: The algorithm to insert an element "newkey" to

Define the term ''complexity of an algorithm, Define the term 'complexity o...

Define the term 'complexity of an algorithm; Complexity of an algorithm is the calculate of analysis of algorithm. Analyzing an algorithm means predicting the resources that th

Array, how to define the size of array

how to define the size of array

Explain dijkstra''s algorithm, Explain Dijkstra's algorithm Dijkstra's ...

Explain Dijkstra's algorithm Dijkstra's algorithm: This problem is concerned with finding the least cost path from an originating node in a weighted graph to a destination node

How do you find the complexity of an algorithm, How do you find the complex...

How do you find the complexity of an algorithm?  Complexity of an algorithm is the measure of analysis of algorithm. Analyzing an algorithm means predicting the resources that

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