Documentation for method succ

Documentation for method succ, assembled from the following types:

Numeric.succ

From Numeric

succ

method succ(Numerid:D:)

Returns the number incremented by one (successor).

Date.succ

From Date

succ

method succ(Date:D:) returns Date:D

Returns the following day

Str.succ

From Str

succ

method succ(Str:D) returns Str:D

Returns the string incremented by one.

String increment is "magical". It searches for the last alphanumeric sequence that is not preceeded by a dot, and increments it.

'12.34'.succ      # 13.34
'img001.png'.succ # img002.png

The actual incrementation step works by mapping the last alphanumeric character to a character range it belongs to, and chosing the next character in that range, carrying to the previous letter on overflow.

'aa'.succ   # ab
'az'.succ   # ba
'109'.succ  # 110
'α'.succ    # β
'a9'.succ   # b0

String increment is Unicode-aware, and generally works for scripts where a character can be uniquely classified as belonging to one range of characters.