User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

harlowe:range [2017/10/09 20:39] (current)
Line 1: Line 1:
 +**(range: // [[harlowe:​Number|Number]],​ Number//) -> //​[[harlowe:​Array|array]]//​**
 +Produces an [[harlowe:​array|array]] containing an inclusive range of whole [[harlowe:​number|number]] from a to b,
 +in ascending order.
 +=== Example usage: ===
 +''​%%(range:​1,​14)%%''​ is equivalent to ''​%%(a:​1,​2,​3,​4,​5,​6,​7,​8,​9,​10,​11,​12,​13,​14)%%''​
 +''​%%(range:​2,​-2)%%''​ is equivalent to ''​%%(a:​-2,​-1,​0,​1,​2)%%''​
 +=== Rationale: ===
 +This macro is a shorthand for defining an array that contains a sequence of
 +integer values. Rather than writing out all of the numbers, you can simply provide
 +the first and last numbers.
 +=== Details: ===
 +Certain kinds of macros, like [[harlowe:​either|(either:​)]] or [[harlowe:​dataset|(dataset:​)]],​ accept sequences of values. You can
 +use (range:) with these in conjunction with the ''​%%...%%''​ spreading operator:
 +''​%%(dataset:​ ...(range:​2,​6))%%''​ is equivalent to ''​%%(dataset:​ 2,​4,​5,​6,​7)%%'',​ and
 +''​%%(either:​ ...(range:​1,​5))%%''​ is equivalent to ''​%%(random:​ 1,​5)%%''​.
 +=== See also: ===
harlowe/range.txt ยท Last modified: 2017/10/09 20:39 (external edit)