W3cubDocs

/Pony

Reverse[optional A: (Real[A] val & (I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val | U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val | F32 val | F64 val))]

[Source]

Produces a decreasing range [max, min] with step dec, for any Number type. (i.e. the reverse of Range)

Example program:

use "collections"
actor Main
  new create(env: Env) =>
    for e in Reverse(10, 2, 2) do
      env.out.print(e.string())
    end 

Which outputs:

10
8
6
4
2

If dec is 0, produces an infinite series of max.

If dec is negative, produces a range with max as the only value.

class ref Reverse[optional A: (Real[A] val & (I8 val | I16 val | I32 val | 
    I64 val | I128 val | ILong val | 
    ISize val | U8 val | U16 val | 
    U32 val | U64 val | U128 val | 
    ULong val | USize val | F32 val | 
    F64 val))] is
  Iterator[A] ref

Implements

Constructors

create

[Source]

new ref create(
  max: A,
  min: A,
  dec: A = 1)
: Reverse[A] ref^

Parameters

  • max: A
  • min: A
  • dec: A = 1

Returns

Public Functions

has_next

[Source]

fun box has_next()
: Bool val

Returns

next

[Source]

fun ref next()
: A

Returns

  • A

rewind

[Source]

fun ref rewind()
: None val

Returns

© 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/collections-Reverse