function 2: range
range:
description:
range(start, stop)
range(start, stop, step)
returns a superposition of kets starting at start, and finishing at stop
with step size step, if it is provided, otherwise step with size 1
if start and stop have categories, then so does the result
if the categories differ, then return the empty ket |>
now partially implemented as: start .. stop
in this form, you can't specify the step size
Now we can handle 2D ranges too:
Eg: |-1: -1> .. |1: 1>
examples:
range(|1>, |6>)
|1> + |2> + |3> + |4> + |5> + |6>
range(|number: 7>, |number: 13>)
|number: 7> + |number: 8> + |number: 9> + |number: 10> + |number: 11> + |number: 12> + |number: 13>
range(|2>, |4>, |0.5>)
|2> + |2.5> + |3> + |3.5> + |4>
range(|8>, |3>, |-1>)
|8> + |7> + |6> + |5> + |4> + |3>
-- an example using the new infix operator:
|13> .. |17>
|13> + |14> + |15> + |16> + |17>
-- an example of 2D range using the new infix operator:
|0: 0> .. |1: 1>
|0: 0> + |0: 1> + |1: 0> + |1: 1>
-- and another:
|-1: -1> .. |1: 1>
|-1: -1> + |-1: 0> + |-1: 1> + |0: -1> + |0: 0> + |0: 1> + |1: -1> + |1: 0> + |1: 1>
see also:
srange, sp2seq
Home