How are sequences constructed in the racket guide?

How are sequences constructed in the racket guide?

Sequence Constructors in The Racket Guide introduces sequences. A sequence encapsulates an ordered collection of values. The elements of a sequence can be extracted with one of the for syntactic forms, with the procedures returned by sequence-generate, or by converting the sequence into a stream.

How is the in range function used in racket?

The in-range function generates a sequence of numbers, given an optional starting number (which defaults to 0 ), a number before which the sequence ends, and an optional step (which defaults to 1 ). Using a non-negative integer k directly as a sequence is a shorthand for ( in-range k).

Which is the best sequence in racket for integer iteration?

Returns an infinite sequence (that is also a stream) of exact integers starting with start, where each element is one more than the preceding element. An in-naturals application can provide better performance for integer iteration when it appears directly in a for clause.

Is it better to use a stream as a sequence?

Returns a sequence (that is also a stream) that is equivalent to using lst directly as a sequence. See Pairs and Lists for information on using lists as sequences. An in-list application can provide better performance for list iteration when it appears directly in a for clause.

Which is an example of an in-range end in racket?

The single-argument case ( in-range end) is equivalent to ( in-range 0 end 1). The first number in the sequence is start, and each successive element is generated by adding step to the previous element. The sequence stops before an element that would be greater or equal to end if step is non-negative, or less or equal to end if step is negative.

Which is an example of a single argument in racket?

Returns a sequence (that is also a stream) whose elements are numbers. The single-argument case ( in-range end) is equivalent to ( in-range 0 end 1). The first number in the sequence is start, and each successive element is generated by adding step to the previous element.