Changeset 39210 in project


Ignore:
Timestamp:
11/10/20 19:50:43 (3 weeks ago)
Author:
Zipheir
Message:

Font-style consistency and improvement.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/srfi-196

    r39209 r39210  
    6767<procedure>(range length indexer)</procedure>
    6868
    69 Returns a range whose length (number of elements) is length. The indexer procedure returns the nth element (where {{0 ≀ n < length}}) of the range, given {{n}}. This procedure must run in O(1) time. The range returned is compact, although indexer may close over arbitrarily large data structures. The average accessing time of the resulting range is the average time needed to run indexer.
     69Returns a range whose length (number of elements) is {{length}}. The indexer procedure returns the ''n''th element (where 0 ≀ ''n'' < {{length}}) of the range, given ''n''. This procedure must run in O(1) time. The range returned is compact, although {{indexer}} may close over arbitrarily large data structures. The average accessing time of the resulting range is the average time needed to run {{indexer}}.
    7070
    7171====== Examples
     
    8686 start, (+ start step), (+ start (* 2 step)), 
, (+ start (* n step)),
    8787
    88 where {{n}} is the greatest integer such that {{(+ start (* n step)) < end}} if {{step}} is positive, or such that {{(+ start (* n step)) > end}} if {{step}} is negative. It is is an error if an {{n}} satisfying this condition cannot be determined, or if {{step}} is numerically zero. This procedure must run in O(1) time. The average accessing time of the resulting range must be O(1).
     88where ''n'' is the greatest integer such that {{(+ start (* n step)) < end}} if {{step}} is positive, or such that {{(+ start (* n step)) > end}} if {{step}} is negative. It is is an error if an ''n'' satisfying this condition cannot be determined, or if {{step}} is numerically zero. This procedure must run in O(1) time. The average accessing time of the resulting range must be O(1).
    8989
    9090Note that an effect of this definition is that the elements of a range over inexact numbers are enumerated by multiplying the index by the {{step}} value rather than by adding the {{step}} value to itself repeatedly. This reduces the likelihood of roundoff errors.
     
    9999<procedure>(iota-range length [start [step]])</procedure>
    100100
    101 Returns an iota-numeric range, a special case of a range specified by a length (a non-negative exact integer) as well as an inclusive lower bound {{start}} (default 0) and a {{step}} value (default 1), both of which can be exact or inexact real numbers. This constructor produces the sequence
     101Returns an iota-numeric range, a special case of a range specified by a {{length}} (a non-negative exact integer) as well as an inclusive lower bound {{start}} (default 0) and a {{step}} value (default 1), both of which can be exact or inexact real numbers. This constructor produces the sequence
    102102
    103103 start, (+ start step), (+ start (* 2 step)), 
, (+ start (* (- length 1) step)),
     
    109109<procedure>(vector-range vector)</procedure>
    110110
    111 Returns a range whose elements are those of vector. The procedure must run in O(1) time. The average accessing time of the resulting range must be O(1). It is an error to mutate vector.
     111Returns a range whose elements are those of {{vector}}. The procedure must run in O(1) time. The average accessing time of the resulting range must be O(1). It is an error to mutate {{vector}}.
    112112====== Example
    113113<enscript highlight="scheme">
     
    118118<procedure>(string-range string)</procedure>
    119119
    120 Returns a range whose elements are those of string. It is an error to mutate string. This procedure must run in O(n) time, where {{n}} is the length of string. The average accessing time of the resulting range must be O(1).
     120Returns a range whose elements are those of {{string}}. It is an error to mutate {{string}}. This procedure must run in O(''n'') time, where ''n'' is the length of {{string}}. The average accessing time of the resulting range must be O(1).
    121121
    122122In a Scheme that guarantees O(1) random access to strings, range-ref on a range created by string-range can simply call string-ref, and the resulting range is compact. But if only O(n) access is available, this procedure may have to copy the string's characters into a vector, resulting in an expanded range.
     
    129129<procedure>(range-append range ...)</procedure>
    130130
    131 Returns a range whose elements are the elements of the ranges in order. This procedure must run in O(n) + O(k) time, where {{n}} is the total number of elements in all the ranges and {{k}} is the number of ranges. The result is usually expanded but may be compact. The average accessing time of the resulting range is asymptotically bounded by maximum of the average accessing times of the ranges.
     131Returns a range whose elements are the elements of the {{range}}s in order. This procedure must run in O(''n'') + O(''k'') time, where ''n'' is the total number of elements in all the ranges and ''k'' is the number of {{range}}s. The result is usually expanded but may be compact. The average accessing time of the resulting range is asymptotically bounded by maximum of the average accessing times of the {{range}}s.
    132132====== Example
    133133<enscript highlight="scheme">
     
    140140<procedure>(range? obj)</procedure>
    141141
    142 Returns {{#t}} if obj is a range and {{#f}} otherwise. This procedure must run in O(1) time.
     142Returns {{#t}} if {{obj}} is a range and {{#f}} otherwise. This procedure must run in O(1) time.
    143143
    144144<procedure>(range=? equal range1 range2 ...)</procedure>
    145145
    146 Returns {{#t}} if all the ranges are of the same length and if their corresponding values are the same in the sense of equal, and {{#f}} otherwise. The runtime of this procedure is O(s) + O(k), where {{s}} is the sum of the total accessing times of the ranges and {{k}} is the number of ranges.
     146Returns {{#t}} if all the {{range}}s are of the same length and if their corresponding values are the same in the sense of {{equal}}, and {{#f}} otherwise. The runtime of this procedure is O(''s'') + O(''k''), where ''s'' is the sum of the total accessing times of the ranges and ''k'' is the number of ranges.
    147147====== Examples
    148148<enscript highlight="scheme">
     
    163163<procedure>(range-ref range n)</procedure>
    164164
    165 Returns the nth element of range. It is an error if {{n}} is less than 0 or greater than or equal to the length of range. The running time of this procedure must be asymptotically equal to the average accessing time of range.
     165Returns the {{n}}th element of range. It is an error if {{n}} is less than 0 or greater than or equal to the length of {{range}}. The running time of this procedure must be asymptotically equal to the average accessing time of {{range}}.
    166166====== Examples
    167167<enscript highlight="scheme">
     
    189189<procedure>(range-split-at range index)</procedure>
    190190
    191 Returns two values: {{(range-take range index)}} and {{(range-drop range index)}}. It is an error if index is not an exact integer between 0 and the length of range, both inclusive. This procedure must run in O(1) time.
     191Returns two values: {{(range-take range index)}} and {{(range-drop range index)}}. It is an error if {{index}} is not an exact integer between 0 and the length of {{range}}, both inclusive. This procedure must run in O(1) time.
    192192====== Example
    193193<enscript highlight="scheme">
     
    200200<procedure>(subrange range start end)</procedure>
    201201
    202 Returns a range which contains the elements of range from index {{start}}, inclusive, through index {{end}}, exclusive. This procedure must run in O(1) time. The average accessing time of the resulting range is asymptotically bounded by the average accessing time of range.
     202Returns a range which contains the elements of range from index {{start}}, inclusive, through index {{end}}, exclusive. This procedure must run in O(1) time. The average accessing time of the resulting range is asymptotically bounded by the average accessing time of {{range}}.
    203203====== Examples
    204204<enscript highlight="scheme">
     
    212212<procedure>(range-segment range length)</procedure>
    213213
    214 Returns a list of ranges representing the consecutive subranges of length length. The last range is allowed to be shorter than length. The procedure must run in O(k) time, where {{k}} is the number of ranges returned. The average accessing time of the ranges is asymptotically bounded by the average accessing time of range.
     214Returns a list of ranges representing the consecutive subranges of length {{length}}. The last range is allowed to be shorter than {{length}}. The procedure must run in O(''k'') time, where ''k'' is the number of ranges returned. The average accessing time of the ranges is asymptotically bounded by the average accessing time of {{range}}.
    215215
    216216<enscript highlight="scheme">
     
    228228<procedure>(range-take-right range count)
    229229====== Description
    230 Returns a range which contains the first/last count elements of range. The average accessing time of the resulting ranges is asymptotically bounded by the average accessing time of range.
     230Returns a range which contains the first/last {{count}} elements of {{range}}. The average accessing time of the resulting ranges is asymptotically bounded by the average accessing time of {{range}}.
    231231====== Examples
    232232<enscript highlight="scheme">
     
    244244
    245245====== Description
    246 Returns a range which contains all except the first/last count elements of range. These procedures must run in O(1) time. The average accessing time of the resulting ranges is asymptotically bounded by the average accessing time respectively of range.
     246Returns a range which contains all except the first/last {{count}} elements of {{range}}. These procedures must run in O(1) time. The average accessing time of the resulting ranges is asymptotically bounded by the average accessing time respectively of {{range}}.
    247247
    248248<enscript highlight="scheme">
     
    256256<procedure>(range-count pred range1 range2 ...)</procedure>
    257257
    258 Applies {{pred}} element-wise to the elements of ranges and returns the number of applications which returned true values. If more than one range is given and not all ranges have the same length, range-count terminates when the shortest range is exhausted. The runtime of this procedure is O(s) where {{s}} is the sum of the total accessing times of the ranges.
     258Applies {{pred}} element-wise to the elements of {{range}}s and returns the number of applications which returned true values. If more than one range is given and not all ranges have the same length, range-count terminates when the shortest range is exhausted. The runtime of this procedure is O(''s'') where ''s'' is the sum of the total accessing times of the {{range}}s.
    259259====== Examples
    260260<enscript highlight="scheme">
     
    265265<procedure>(range-any pred range1 range2 ...)</procedure>
    266266
    267 Applies {{pred}} element-wise to the elements of the ranges and returns true if {{pred}} returns true on any application. Specifically it returns the last value returned by {{pred}}. Otherwise, {{#f}} is returned. If more than one range is given and not all ranges have the same length, range-any terminates when the shortest range is exhausted. The runtime of this procedure is O(s) where {{s}} is the sum of the total accessing times of the ranges.
     267Applies {{pred}} element-wise to the elements of the {{range}}s and returns true if {{pred}} returns true on any application. Specifically it returns the last value returned by {{pred}}. Otherwise, {{#f}} is returned. If more than one range is given and not all ranges have the same length, {{range-any}} terminates when the shortest range is exhausted. The runtime of this procedure is O(''s'') where ''s'' is the sum of the total accessing times of the {{range}}s.
    268268====== Examples
    269269<enscript highlight="scheme">
     
    275275<procedure>(range-every pred range)</procedure>
    276276
    277 Applies {{pred}} element-wise to the elements of the ranges and returns true if {{pred}} returns true on every application. Specifically it returns the last value returned by {{pred}} , or {{#t}} if {{pred}} was never invoked. Otherwise, {{#f}} is returned. If more than one range is given and not all ranges have the same length, range-every terminates when the shortest range is exhausted. The runtime of this procedure is O(s) + O(k), where {{s}} is the sum of the total accessing times of the ranges and {{k}} is the number of ranges.
     277Applies {{pred}} element-wise to the elements of the {{range}}s and returns true if {{pred}} returns true on every application. Specifically it returns the last value returned by {{pred}} , or {{#t}} if {{pred}} was never invoked. Otherwise, {{#f}} is returned. If more than one range is given and not all ranges have the same length, range-every terminates when the shortest range is exhausted. The runtime of this procedure is O(''s'') + O(''k''), where ''s'' is the sum of the total accessing times of the {{range}}s and ''k'' is the number of {{range}}s.
    278278====== Examples
    279279<enscript highlight="scheme">
     
    291291
    292292====== Description
    293 Applies {{proc}} element-wise to the elements of the ranges and returns a range/list/vector of the results, in order. If more than one range is given and not all ranges have the same length, these procedures terminate when the shortest range is exhausted. The dynamic order in which {{proc}} is actually applied to the elements is unspecified. The runtime of these procedures is O(s) where {{s}} is the sum of the total accessing times of the ranges. The range-map procedure eagerly computes its result and returns an expanded range. Its average accessing time is O(1).
     293Applies {{proc}} element-wise to the elements of the {{range}}s and returns a range/list/vector of the results, in order. If more than one range is given and not all ranges have the same length, these procedures terminate when the shortest range is exhausted. The dynamic order in which {{proc}} is actually applied to the elements is unspecified. The runtime of these procedures is O(''s'') where ''s'' is the sum of the total accessing times of the {{range}}s. The range-map procedure eagerly computes its result and returns an expanded range. Its average accessing time is O(1).
    294294====== Examples
    295295<enscript highlight="scheme">
     
    306306<procedure>(range-for-each proc range1 range2 ...)</procedure>
    307307
    308 Applies {{proc}} element-wise to the elements of the ranges in order. Returns an unspecified result. If more than one range is given and not all ranges have the same length, range-for-each terminates when the shortest range is exhausted. The runtime of this procedure is O(s) where {{s}} is the sum of the total accessing times of the ranges.
     308Applies {{proc}} element-wise to the elements of the {{range}}s in order. Returns an unspecified result. If more than one range is given and not all ranges have the same length, {{range-for-each}} terminates when the shortest range is exhausted. The runtime of this procedure is O(''s'') where ''s'' is the sum of the total accessing times of the {{range}}s.
    309309====== Example
    310310<enscript highlight="scheme">
     
    321321
    322322====== Description
    323 Applies {{proc}} element-wise to the elements of the ranges and returns a range/list of the true values returned by {{proc}}. If more than one range is given and not all ranges have the same length, these procedures terminate when the shortest range is exhausted. The dynamic order in which {{proc}} is actually applied to the elements is unspecified. The range-filter-map procedure eagerly computes its result and returns an expanded range. The runtime of these procedures is O(n) where {{n}} is the sum of the total accessing times of the ranges.
     323Applies {{proc}} element-wise to the elements of the {{range}}s and returns a range/list of the true values returned by {{proc}}. If more than one range is given and not all ranges have the same length, these procedures terminate when the shortest range is exhausted. The dynamic order in which {{proc}} is actually applied to the elements is unspecified. The {{range-filter-map}} procedure eagerly computes its result and returns an expanded range. The runtime of these procedures is O(''n'') where ''n'' is the sum of the total accessing times of the {{range}}s.
    324324====== Examples
    325325<enscript highlight="scheme">
     
    345345
    346346====== Description
    347 Returns a range/list containing the elements of range that satisfy / do not satisfy {{pred}}. The runtime of these procedures is O(s) where {{s}} is the sum of the total accessing times of the ranges.
    348 
    349 The range-filter and range-remove procedures eagerly compute their results and return expanded ranges. Their average accessing time is O(1).
     347Returns a range/list containing the elements of {{range}} that satisfy / do not satisfy {{pred}}. The runtime of these procedures is O(''s'') where ''s'' is the sum of the total accessing times of the {{range}}s.
     348
     349The {{range-filter}} and {{range-remove}} procedures eagerly compute their results and return expanded ranges. Their average accessing time is O(1).
    350350====== Examples
    351351<enscript highlight="scheme">
     
    369369
    370370====== Description
    371 Folds {{kons}} over the elements of ranges in order / reverse order. {{kons}} is applied as ({{kons}} state (range-ref range1 i) (range-ref range2 i) 
) where state is the result of the previous invocation and {{i}} is the current index. For the first invocation, nil is used as the first argument. Returns the result of the last invocation, or nil if there was no invocation. If more than one range is given and not all ranges have the same length, these procedures terminate when the shortest range is exhausted. The runtime of these procedures must be O(s) where {{s}} is the sum of the total accessing times of the ranges.
     371Folds {{kons}} over the elements of {{range}}s in order / reverse order. {{kons}} is applied as {{(kons state (range-ref range1 i) (range-ref range2 i) 
)}} where {{state}} is the result of the previous invocation and ''i'' is the current index. For the first invocation, {{nil}} is used as the first argument. Returns the result of the last invocation, or {{nil}} if there was no invocation. If more than one range is given and not all ranges have the same length, these procedures terminate when the shortest range is exhausted. The runtime of these procedures must be O(''s'') where ''s'' is the sum of the total accessing times of the {{range}}s.
    372372====== Examples
    373373<enscript highlight="scheme">
     
    395395
    396396====== Description
    397 Applies {{pred}} element-wise to the elements of ranges and returns the index of the first/last element at which {{pred}} returns true. Otherwise, returns {{#f}}. If more than one range is given and not all ranges have the same length, range-index terminates when the shortest range is exhausted. It is an error if the ranges passed to range-index-right do not all have the same lengths. The runtime of these procedures must be O(s) where {{s}} is the sum of the total accessing times of the ranges.
     397Applies {{pred}} element-wise to the elements of {{range}}s and returns the index of the first/last element at which {{pred}} returns true. Otherwise, returns {{#f}}. If more than one range is given and not all ranges have the same length, {{range-index}} terminates when the shortest range is exhausted. It is an error if the ranges passed to {{range-index-right}} do not all have the same lengths. The runtime of these procedures must be O(''s'') where ''s'' is the sum of the total accessing times of the {{range}}s.
    398398====== Examples
    399399<enscript highlight="scheme">
     
    413413
    414414====== Description
    415 Returns a range containing the leading/trailing elements of range that satisfy {{pred}} up to the first/last one that does not. The runtime of these procedures is asymptotically bounded by the total accessing time of the range. The average accessing time of the resulting range is O(1).
     415Returns a range containing the leading/trailing elements of {{range}} that satisfy {{pred}} up to the first/last one that does not. The runtime of these procedures is asymptotically bounded by the total accessing time of the range. The average accessing time of the resulting range is O(1).
    416416====== Examples
    417417<enscript highlight="scheme">
     
    431431
    432432====== Description
    433 Returns a range that omits leading/trailing elements of range that satisfy {{pred}} until the first/last one that does not. The runtime of these procedures is asymptotically bounded by the total accessing time of the range. The average accessing time of the resulting range is O(1).
     433Returns a range that omits leading/trailing elements of {{range}} that satisfy {{pred}} until the first/last one that does not. The runtime of these procedures is asymptotically bounded by the total accessing time of the range. The average accessing time of the resulting range is O(1).
    434434====== Examples
    435435<enscript highlight="scheme">
     
    452452
    453453====== Description
    454 Returns a list/vector/string containing the elements of range in order. It is an error to modify the result of range->vector or of range->string. In the case of range-> string, it is an error if any element of range is not a character. The running times of these procedures is O(s) where {{s}} is the total accessing time for range.
     454Returns a list/vector/string containing the elements of {{range}} in order. It is an error to modify the result of {{range->vector}} or of {{range->string}}. In the case of {{range-> string}}, it is an error if any element of {{range}} is not a character. The running times of these procedures is O(''s'') where ''s'' is the total accessing time for {{range}}.
    455455====== Examples
    456456<enscript highlight="scheme">
     
    465465<procedure>(vector->range vector)</procedure>
    466466
    467 Returns an expanded range whose elements are those of vector. Note that, unlike vector-range, it is not an error to mutate vector; future mutations of vector are guaranteed not to affect the range returned by vector->range. This procedure must run in O(n) where {{n}} is the length of vector. Otherwise, this procedure is equivalent to vector-range.
     467Returns an expanded range whose elements are those of {{vector}}. Note that, unlike {{vector-range}}, it is not an error to mutate {{vector}}; future mutations of {{vector}} are guaranteed not to affect the range returned by {{vector->range}}. This procedure must run in O(''n'') time, where ''n'' is the length of {{vector}}. Otherwise, this procedure is equivalent to {{vector-range}}.
    468468====== Example
    469469<enscript highlight="scheme">
     
    473473<procedure>(range->generator range)</procedure>
    474474
    475 Returns a SRFI 158 generator that generates the elements of range in order. This procedure must run in O(1) time, and the running time of each call of the generator is asymptotically bounded by the average accessing time of range.
     475Returns a SRFI 158 generator that generates the elements of {{range}} in order. This procedure must run in O(1) time, and the running time of each call of the generator is asymptotically bounded by the average accessing time of {{range}}.
    476476====== Example
    477477<enscript highlight="scheme">
Note: See TracChangeset for help on using the changeset viewer.