NAME
std/math/range - Format integer lists as compact display ranges.
SYNOPSIS
from std/math/range import abbreviate;
let values := [ 3, 4, 9, 10, 11, 12, 15 ];
let compact := abbreviate( values );
# [ "3", "4", "9-12", "15" ]
IMPLEMENTATION SUPPORT
This module is supported by all implementations of ZuzuScript.
DESCRIPTION
This module exports abbreviate, which converts a list of test numbers into compact range labels.
Only runs of three or more consecutive integers are collapsed into a range token like 9-12. Single values and two-item runs are emitted as individual tokens.
EXPORTS
Functions
abbreviate(Array values)Parameters:
valuesis an array of numbers. Returns:Array. Returns compact string labels for the provided numbers.The input may be unsorted and may contain duplicates; values are normalized before abbreviation.
COPYRIGHT AND LICENCE
std/math/range is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.