mirror of
https://github.com/ruuda/rcl.git
synced 2025-12-23 04:47:19 +00:00
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.
42 lines
1.2 KiB
Markdown
42 lines
1.2 KiB
Markdown
# Standard library
|
|
|
|
The <abbr>RCL</abbr> 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
|
|
|
|
```rcl
|
|
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.
|
|
|
|
```rcl
|
|
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](imports.md#import-location), and are subject to the same
|
|
[sandbox restrictions](rcl_evaluate.md#-sandbox-mode). The file must contain
|
|
valid <abbr>UTF-8</abbr> text without byte order mark.
|