This is part of updating the implementation to have a single number type. I have to admit, doing this, I'm hesitant again. I would really like len functions to return Int, or to clarify in the types that std.range accepts only integers. But let's experiment, implement this, and get a feel for it before I make a call.
1.2 KiB
Standard library
The RCL standard library is a dict of values that is in scope by
default under the name std. Most of the built-in functionality is not in this
std dict, but in methods on the builtin types. See the next chapters for those.
empty_set
std.empty_set: Set[Void]
An empty set. This constant exists, because without type annotations, {} is an
empty dict rather than an empty set. This constant is the standard way to refer
to an empty set.
range
std.range: (lower: Number, upper: Number) -> List[Number]
Return the range of integers lower through upper. The lower bound is
inclusive and the upper bound is exclusive. When the lower bound is greater
than the upper bound, range returns an empty list.
std.range(3, 7)
// Evaluates to:
[3, 4, 5, 6]
std.range(7, 3)
// Evaluates to:
[]
read_file_utf8
std.read_file_utf8: (path: String) -> String
Return the contents of the file at the given path. Paths are treated the same as for imports, and are subject to the same sandbox restrictions. The file must contain valid UTF-8 text without byte order mark.