-
-
Notifications
You must be signed in to change notification settings - Fork 0
Numbers And Collections
let exact = 1.50d
let bytes = [1u8, 2u8, 3u8]
let names = setOf(["Ada", "Grace"])
Status: numeric widths, checked/wrapping/saturating integer operators, IEEE floats, exact decimals, arrays, maps, sets, strings, tuples, and iteration execute in the interpreter.
Unsuffixed integer literals remain arbitrary precision during inference, then must fit their
selected type. If context selects none, they default to Int. Width suffixes include forms such as
i8, u64, and the other wired-in integer widths.
| Operators | Meaning |
|---|---|
+ - * |
Checked; overflow reports a typed runtime diagnostic. |
&+ &- &* |
Wrapping modulo the type width. |
| `+ | - |
Integer division truncates toward zero. Division by zero and invalid shift counts are reported. Implicit numeric narrowing is not performed.
Unsuffixed and f64 literals are Float64; f32 explicitly selects Float32. Float32 operations
round at binary32 precision instead of keeping hidden binary64 precision.
Decimal stores an arbitrary-precision coefficient and base-ten scale. Addition, subtraction, and
multiplication are exact. Ordinary division succeeds only for a terminating decimal; explicit
Std.Decimal.divide selects precision and a rounding mode when rounding is intended. Decimal does
not convert implicitly to or from binary floating point.
| Type | Core behavior |
|---|---|
Array[T] |
Ordered sequence and built-in array methods. |
Map[K, V] |
Key/value lookup, update, keys, values, and iteration as (K, V). |
Set[T] |
Membership, insertion/removal, set algebra, and value iteration. |
Str |
Unicode scalar access and text methods. |
| Tuple | Fixed heterogeneous product. |
Collections are values. Standard modules provide the larger operation vocabulary without turning every function into a method.
for pattern in expression obtains a deterministic element type. Built-ins include arrays,
strings, sets, maps, tuples with a common member type, and sums with a common payload type.
User-defined iteration uses Std.Iter.Sequence:
trait Sequence[S, T] {
fn begin(self: &Self) -> S
fn advance(self: &Self, state: S) -> Option[(S, T)]
}
State is passed as a value rather than hidden mutation. Iterator adapters are lazy until consumed.
- Modules And Imports
- Values, Bindings, And Blocks
- Types And Inference
- Records, Sums, And Tuples
- Functions Generics And Traits
- Pattern Language
- Control Flow And Patterns
- Iteration And Loops
- Failure And Propagation
- Numbers And Collections
- Sets Maps And Sequences
- Keyed Structures
- Trees And Hierarchies
- Standard Library
- Output Formatting And Testing
- Tasks And Scopes
- Compile-Time Evaluation
- Typed Macros
- References And Unsafe
- Worked Programs