# Appendix D: Standard library index

> Appendix D: where each part of the Alice standard library is described: Prelude methods on strings, arrays, hashes and numbers, the runtime types for concurrency and numerics, and the .NET base library.

Canonical: https://alice-lang.org/documentation/learn/library-index/

[Documentation index](https://alice-lang.org/documentation/llms.txt) · [Complete book](https://alice-lang.org/llms-full.txt)

Alice's library has three layers. This index tells you where to look.

1. **The Prelude**: Ruby-style methods on built-in types, such as `map`, `strip`, `tally`, `gcd`, and free functions such as `puts` and `format`. Always available.
2. **The Alice runtime**: types for concurrency, parallelism and numerics, such as `Channel(T)`, `Actor(T)`, `Par`, `Atomic` and `Tensor`. Always available.
3. **The .NET base library and NuGet**: everything else, by its .NET name ([chapter 14](https://alice-lang.org/documentation/learn/dotnet.md)).

## The Prelude

| Type                    | Common methods                                                                                                                                                                                                                                                                                             | Reference                                                                                                                                          |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `String`                | `size`, `strip`, `split`, `upcase`, `downcase`, `capitalize`, `includes?`, `starts_with?`, `sub`, `gsub`, `scan`, `match`, `match?`, `chars`, `lines`, `ljust`, `rjust`, `center`, `to_i`, `to_i?`, `to_f`, `reverse`, `tr`, `bytesize`, `camelcase`, `underscore`                                         | [strings](https://alice-lang.org/documentation/library/strings.md), [chapter 5](https://alice-lang.org/documentation/learn/strings.md)             |
| `Char`                  | `upcase`, `downcase`, `letter?`, `digit?`, `whitespace?`, `ord`, `succ`                                                                                                                                                                                                                                    | [strings](https://alice-lang.org/documentation/library/strings.md)                                                                                 |
| `Array`, `List`, ranges | `each`, `each_with_index`, `map`, `select`, `reject`, `find`, `count`, `sum`, `min`, `max`, `minmax`, `sort`, `sort_by`, `uniq`, `reverse`, `first`, `last`, `take`, `drop`, `zip`, `flatten`, `group_by`, `partition`, `tally`, `each_slice`, `each_cons`, `reduce`, `inject`, `join`, `includes?`, `dup` | [collections](https://alice-lang.org/documentation/library/collections.md), [chapter 4](https://alice-lang.org/documentation/learn/collections.md) |
| Arrays, data-parallel   | `prefix_sum`, `segmented_sum`, `histogram`, `compact`, `scatter_add`, `permute`, `sort_by_key`                                                                                                                                                                                                             | [chapter 11](https://alice-lang.org/documentation/learn/parallelism.md)                                                                            |
| `Hash`                  | `[]`, `fetch`, `key?`, `delete`, `each`, `keys`, `values`, `select`, `map`, `min_by`, `max_by`, `sort_by`, `transform_values`, `merge`, `dig`, `to_a`; `Hash(K, V).new(default)`                                                                                                                           | [hashes](https://alice-lang.org/documentation/library/hashes.md), [chapter 4](https://alice-lang.org/documentation/learn/collections.md)           |
| Integers and floats     | `abs`, `even?`, `odd?`, `zero?`, `times`, `upto`, `downto`, `step`, `gcd`, `lcm`, `divmod`, `tdiv`, `remainder`, `clamp`, `between?`, `round`, `floor`, `ceil`, `sqrt`, `to_s(base)`, `to_i64`, `to_f`                                                                                                     | [numbers](https://alice-lang.org/documentation/library/numbers.md), [chapter 3](https://alice-lang.org/documentation/learn/common-concepts.md)     |
| Enums                   | `to_i`, `Color.values`, `Color.names`, `Color.parse`                                                                                                                                                                                                                                                       | [chapter 7](https://alice-lang.org/documentation/learn/sum-types.md)                                                                               |
| Free functions          | `puts`, `print`, `p`, `gets`, `format`, `rand`, `sleep`, `read_file`, `write_file`, `read_lines`, `file_exists?`, `env`, `to_json`, `parse_json`, `exit`                                                                                                                                                   | [files and JSON](https://alice-lang.org/documentation/library/io.md)                                                                               |
| Regular expressions     | `/pattern/flags` literals, `MatchData` with `[]`, `pre_match`, `post_match`, `captures`                                                                                                                                                                                                                    | [regex](https://alice-lang.org/documentation/library/regex.md)                                                                                     |

## The Alice runtime

| Type                                    | Use                                                           | Chapter                                                              |
| --------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------- |
| `Channel(T)`                            | queues between threads                                        | [15](https://alice-lang.org/documentation/learn/async.md)            |
| `Actor(T)`, `Actor(S, T)`, `Supervisor` | isolated state, messages, restarts                            | [15](https://alice-lang.org/documentation/learn/async.md)            |
| `Mutex(T)`, `Atomic`                    | guarded shared state                                          | [10](https://alice-lang.org/documentation/learn/safety.md)           |
| `Par`                                   | `For`, `Map`, `Sum` and other explicit parallel operations    | [11](https://alice-lang.org/documentation/learn/parallelism.md)      |
| `SoA(T)`                                | columnar storage of `@[SoA]` record structs                   | [12](https://alice-lang.org/documentation/learn/performance.md)      |
| `Simd`, `AMath`                         | vector helpers and array math                                 | [numerics](https://alice-lang.org/documentation/library/numerics.md) |
| `Tensor`, `Nn`                          | tensor kernels: dot products, matrix multiply, softmax, norms | [tensors](https://alice-lang.org/documentation/guides/tensors.md)    |
| `CsrMatrix`, `SparseVector`             | sparse linear algebra                                         | [numerics](https://alice-lang.org/documentation/library/numerics.md) |

## The .NET base library

Everything in .NET is available by name. The parts used in this book:

| Namespace                    | For                                                         |
| ---------------------------- | ----------------------------------------------------------- |
| `System`                     | `Math`, `DateTime`, `Random`, `Guid`, `Convert`, exceptions |
| `System.Text`                | `StringBuilder`, encodings                                  |
| `System.Text.Json`           | JSON serialization of records and classes                   |
| `System.IO`                  | `File`, `Path`, `Directory`, streams                        |
| `System.Collections.Generic` | `List`, `Dictionary`, `HashSet`, `Queue`, `Stack`           |
| `System.Linq`                | `Where`, `Select`, `OrderBy` and other LINQ operators       |
| `System.Diagnostics`         | `Stopwatch`, processes                                      |
| `System.Threading.Tasks`     | `Task`, `Task.WhenAll`, `Task.Delay`                        |

Microsoft's [.NET API browser](https://learn.microsoft.com/dotnet/api/) documents all of them.

## Continue reading

- Previous: [Appendix C: Coming from Ruby, Crystal or C#](https://alice-lang.org/documentation/learn/from-ruby.md)
- Next: [Appendix E: Coming in 1.0](https://alice-lang.org/documentation/learn/coming-in-1-0.md)
