Added first section to docs and updated single file with changes from docs

This commit is contained in:
Kyler Olsen 2025-11-02 01:00:08 -06:00
parent c930221520
commit 9ac6750246
3 changed files with 141 additions and 63 deletions

79
docs/changes.md Normal file
View File

@ -0,0 +1,79 @@
---
Title: Stack Language Specification
Prev:
Next:
---
# Stack Language Specification
**Version**: 0.8
**Status**: Draft Specification
**Changes**:
- 0.5 (AI)
1. **Escape sequences** - Added a complete list of escape sequences for string literals
2. **Type Tuples** - Defined them as function signatures representing stack effects
3. **Control flow TokenStrings** - Clarified that `if`, `while`, `match`, etc. use TokenStrings
4. **Generic constructs** - Clarified that generics need trait constraints when operations are performed
5. **Stack manipulation traits** - Combined into a single `Stackable` trait
6. **Size trait** - Added proper definition inheriting from `Addable`, `Comparable`, and `Convertible`
7. **Empty traits** - Clarified that traits can be empty (especially when used with inheritance)
8. **Trait inheritance** - Fixed syntax to require both `inher` and `trait` declarations
9. **Array combinators** - Clarified that the functions inside parse their TokenStrings
10. **`::` in TokenStrings** - Clarified it should NOT be used in trait/impl contexts
- 0.5.1 (Human)
1. Created TODOs
2. Made various corrections (not everything was corrected)
3. Reviewed and corrected some code blocks
4. Made a few adjustments manually
- 0.6 (AI)
1. **Operator descriptions** - Added natural language descriptions for all built-in operators
2. **Operators vs Functions** - Clarified distinction and naming rules
3. **Generic trait syntax** - Documented `<>` syntax for generic traits
4. **Generic trait inheritance** - Clarified rules for inheriting from generic traits
5. **Code block types** - Distinguished actual language definitions from examples
6. **Trait appendix** - Created comprehensive trait definitions appendix
7. **TokenString contexts** - Listed all control flow operators and their parsing behavior
8. **Lambda operator** - Added specification for lambda operator
9. **Type parameter enforcement** - Documented current parsing behavior
10. **Identifier literal requirements** - Specified `::` rules for different contexts
11. **Trait implementation rules** - Clarified implementation semantics
12. **Type conversions** - Changed to explicit conversion functions
13. **Memory management** - Moved to appendix as future feature
14. **Module system** - Added appendix entry for future imports
15. **Examples section** - Moved to appendix
16. **Syntax summary** - Moved to appendix and expanded
- 0.6.1 (AI)
1. **Variadic arguments** - Decision: Use array syntax for variable arguments (no special variadic syntax yet)
2. **Inheritance before trait** - Decision: Yes, inheritance declarations must come before trait definition
3. **`inher` operator** - Decision: No, merge inheritance into trait operator (removed `inher`)
4. **Separate `inher` vs `impl`** - Decision: Keep them separate (impl is for implementations only)
- 0.6.2 (Human)
1. Created TODOs
2. Made various corrections (not everything was corrected)
3. Reviewed and corrected some code blocks
4. Made a few adjustments manually
5. Reversed removing `inher`
- 0.7 (AI)
1. **Operator definition** - Clarified that operators can be user/library defined via trait implementation
2. **Generic function syntax** - Fixed to use trait constraints in type tuple, not generic parameters
3. **Variable arguments with Iterable** - Changed array syntax to Iterable trait for variable args
4. **Example classifications** - Cleaned up "Actual Language Definitions" vs examples distinction
5. **Struct field access** - Clarified that get and set consume their arguments
6. **Section 6 rename** - Renamed "Operators (Postfix)" to "Built-in Operators"
7. **Module syntax** - Added `::` prefix for module imports
8. **Module alias options** - Added multiple alias syntax options
- 0.7.1 (Human)
1. Formatting changes
- 0.7.2 (Human)
1. Removed AI editing restrictions of reviewed code blocks
- 0.8 (AI)
1. **Document reorganization** - Restructured for user-focused learning
2. **Section consolidation** - Moved implementation details to appendices
3. **Minimal duplication** - Added cross-references instead of repeating content
4. **Shorter sections** - Split large sections into focused subsections
5. **New appendices** - Added Standard Library and Operator references
6. **Tutorial content** - Added beginner tutorials to Appendix G
7. **Trait reference** - Consolidated all trait definitions in Appendix B
8. **Grammar simplification** - Referenced Implementable trait instead of repeating
---

View File

@ -32,5 +32,6 @@ Next: Overview
**Addendum**: **Addendum**:
- [Missing Features](./missing_features.html) - [Missing Features](./missing_features.html)
- [SE 3250 Assignment Details](./se_3250_assignment_details.html) - [SE 3250 Assignment Details](./se_3250_assignment_details.html)
- [Changed](./changes.html)
--- ---

View File

@ -164,7 +164,7 @@ This specification is organized to support both learning and reference:
- Example: `::Addable` pushes the identifier `Addable` onto the stack - Example: `::Addable` pushes the identifier `Addable` onto the stack
- Example: `::Point` pushes the identifier `Point` onto the stack - Example: `::Point` pushes the identifier `Point` onto the stack
> **Advanced Usage**: See Section 11.2 for complete identifier literal rules and context-dependent behavior. > **Advanced Usage**: See [Section 11.2](./advanced_topics.html#112-identifier-literals) for complete identifier literal rules and context-dependent behavior.
### 2.3 Literals ### 2.3 Literals
@ -244,7 +244,7 @@ You can explicitly annotate literal types:
**Pointer Types** **Pointer Types**
Raw pointers (`ptr`) are a future feature. See Appendix F for the planned pointer type system. Raw pointers (`ptr`) are a future feature. See [Appendix F](./memory_management.html) for the planned pointer type system.
> **Related**: See Section 8 for the complete type system, including composite types and type inference. > **Related**: See Section 8 for the complete type system, including composite types and type inference.
@ -282,7 +282,7 @@ roll // ( n times -- ) Rotate n items, times times
1 2 3 depth // => 1 2 3 3 1 2 3 depth // => 1 2 3 3
``` ```
> **Implementation Details**: Stack operations implement the `::Stackable` trait. See Appendix B for the complete trait definition. > **Implementation Details**: Stack operations implement the `::Stackable` trait. See [Appendix B](./complete_trait_reference.html) for the complete trait definition.
### 4.2 Arithmetic Operators ### 4.2 Arithmetic Operators
@ -307,7 +307,7 @@ Basic arithmetic operations work on numeric types:
2 10 ^ // => 1024 2 10 ^ // => 1024
``` ```
> **Implementation Details**: Arithmetic operators implement the `::Addable`, `::Multiplyable`, `::Exponentiable`, and `::Logarithmic` traits. See Appendix B for complete trait definitions and Appendix C for the full operator reference. > **Implementation Details**: Arithmetic operators implement the `::Addable`, `::Multiplyable`, `::Exponentiable`, and `::Logarithmic` traits. See [Appendix B](./complete_trait_reference.html) for complete trait definitions and [Appendix C](./complete_operator_reference.html) for the full operator reference.
### 4.3 Comparison Operators ### 4.3 Comparison Operators
@ -329,7 +329,7 @@ Comparison operations return boolean values:
10 5 < // => false 10 5 < // => false
``` ```
> **Implementation Details**: Comparison operators implement the `::Orderable` and `::Equatable` traits. See Appendix B for complete trait definitions. > **Implementation Details**: Comparison operators implement the `::Orderable` and `::Equatable` traits. See [Appendix B](./complete_trait_reference.html) for complete trait definitions.
### 4.4 Logical Operators ### 4.4 Logical Operators
@ -351,7 +351,7 @@ false not // => true
5 0 and // => 0 (falsy) 5 0 and // => 0 (falsy)
``` ```
> **Implementation Details**: Logical operators implement the `::Logical` trait. See Appendix B for the complete trait definition and truthiness rules. > **Implementation Details**: Logical operators implement the `::Logical` trait. See [Appendix B](./complete_trait_reference.html) for the complete trait definition and truthiness rules.
### 4.5 Bitwise Operators ### 4.5 Bitwise Operators
@ -374,7 +374,7 @@ Bitwise operations work on integer types:
4 2 shl // => 16 4 2 shl // => 16
``` ```
> **Implementation Details**: Bitwise operators implement the `::Bitwise` trait. See Appendix B for the complete trait definition. > **Implementation Details**: Bitwise operators implement the `::Bitwise` trait. See [Appendix B](./complete_trait_reference.html) for the complete trait definition.
--- ---
@ -389,7 +389,7 @@ Functions differ from operators:
- **Functions** are user-defined procedures that use operators - **Functions** are user-defined procedures that use operators
- Operators and functions cannot share names - Operators and functions cannot share names
> **Related**: See Section 1 "Operators vs Functions" for a complete explanation of the distinction. > **Related**: See [Section 1 "Operators vs Functions"](./overview.html#operators-vs-functions) for a complete explanation of the distinction.
### 5.2 Defining Functions ### 5.2 Defining Functions
@ -413,9 +413,9 @@ The function signature specifies stack effects (what is consumed and produced),
10 3 divmod // => 3 1 (quotient remainder) 10 3 divmod // => 3 1 (quotient remainder)
``` ```
**Function Bodies**: The `{ }` braces contain a TokenString that is parsed as the function body when the function is defined. See Section 5.5 for details on TokenStrings. **Function Bodies**: The `{ }` braces contain a TokenString that is parsed as the function body when the function is defined. See [Section 5.5](./functions.html#55-token-strings) for details on TokenStrings.
> **Related**: See Section 10.2 for generic functions with type parameters. > **Related**: See [Section 10.2](./generic_programming.html#102-generic-functions) for generic functions with type parameters.
### 5.3 Calling Functions ### 5.3 Calling Functions
@ -507,7 +507,7 @@ The `lambda` operator converts a TokenString into a callable code block that can
[1 2 3 4] double map // => [2 4 6 8] [1 2 3 4] double map // => [2 4 6 8]
``` ```
> **Related**: See Section 11.1 for the `eval` operator used to execute lambdas. > **Related**: See [Section 11.1](advanced_topics.html#111-dynamic-code-evaluation) for the `eval` operator used to execute lambdas.
--- ---
@ -705,7 +705,7 @@ point ::x get // Get x field (consumes point and ::x)
point dup ::x get 2 * over ::y get + // (point.x * 2) + point.y point dup ::x get 2 * over ::y get + // (point.x * 2) + point.y
``` ```
> **Note**: Structs can be generic. See Section 10.3 for details on generic data structures. > **Note**: Structs can be generic. See [Section 10.3](./generic_programming.html#103-generic-data-structures) for details on generic data structures.
### 7.2 Unions ### 7.2 Unions
@ -734,9 +734,9 @@ Option::None // Creates Option::None
"error" Result::Err // Creates Result::Err("error") "error" Result::Err // Creates Result::Err("error")
``` ```
**Pattern Matching**: Unions are typically used with pattern matching (Section 6.5) to handle different variants. **Pattern Matching**: Unions are typically used with pattern matching ([Section 6.5](./control_flow.html#65-pattern-matching)) to handle different variants.
> **Note**: Unions can be generic. See Section 10.3 for details on generic data structures. > **Note**: Unions can be generic. See [Section 10.3](./generic_programming.html#103-generic-data-structures) for details on generic data structures.
### 7.3 Enums ### 7.3 Enums
@ -811,7 +811,7 @@ These operations take TokenString arguments containing function bodies:
[1 2 3 4] 2 window // Sliding window: [[1 2] [2 3] [3 4]] [1 2 3 4] 2 window // Sliding window: [[1 2] [2 3] [3 4]]
``` ```
> **Implementation Details**: Array operations implement various traits including `::ArrayOf<T>`, `::Selectable<T>`, `::Sliceable`, and `::Sized`. See Appendix B for complete trait definitions and Appendix A for the full array operation reference. > **Implementation Details**: Array operations implement various traits including `::ArrayOf<T>`, `::Selectable<T>`, `::Sliceable`, and `::Sized`. See [Appendix B](./complete_trait_reference.html) for complete trait definitions and [Appendix A](./standard_library.html) for the full array operation reference.
--- ---
@ -862,7 +862,7 @@ The language distinguishes between types (what things are) and traits (how thing
} ::Point impl } ::Point impl
``` ```
> **Related**: See Section 9 for the complete trait system and Appendix B for all standard trait definitions. > **Related**: See [Section 9](trait_system.html) for the complete trait system and [Appendix B](./complete_trait_reference.html) for all standard trait definitions.
### 8.2 Type Inference ### 8.2 Type Inference
@ -897,7 +897,7 @@ parse // May need type context to know what to parse to
"hello" identity // T inferred as String "hello" identity // T inferred as String
``` ```
> **Related**: See Section 10 for generic programming and type parameter inference. > **Related**: See [Section 10](./generic_programming.html) for generic programming and type parameter inference.
### 8.3 Type Tuples ### 8.3 Type Tuples
@ -990,7 +990,7 @@ The language provides many built-in traits:
- `::Number` - Composite numeric operations - `::Number` - Composite numeric operations
- And many more... - And many more...
> **Complete Reference**: See Appendix B for all standard trait definitions with complete documentation. > **Complete Reference**: See [Appendix B](./complete_trait_reference.html) for all standard trait definitions with complete documentation.
### 9.2 Defining Traits ### 9.2 Defining Traits
@ -1058,7 +1058,7 @@ Traits can have methods or be empty (marker traits). Empty traits are typically
} ::Rectangle impl } ::Rectangle impl
``` ```
> **More Examples**: See Appendix G for complete implementation examples and tutorials. > **More Examples**: See [Appendix G](./examples_and_tutorials.html) for complete implementation examples and tutorials.
### 9.4 Trait Inheritance ### 9.4 Trait Inheritance
@ -1134,7 +1134,7 @@ Traits can be used as type constraints in function signatures:
### 9.6 Standard Traits Overview ### 9.6 Standard Traits Overview
This section provides a brief overview of all standard traits. For complete definitions with all methods and documentation, see Appendix B. This section provides a brief overview of all standard traits. For complete definitions with all methods and documentation, see [Appendix B](./complete_trait_reference.html).
**Stack Operations**: **Stack Operations**:
- `::Stackable` - Fundamental stack manipulation (dup, drop, swap, over, rot, pick, roll, depth) - `::Stackable` - Fundamental stack manipulation (dup, drop, swap, over, rot, pick, roll, depth)
@ -1176,7 +1176,7 @@ This section provides a brief overview of all standard traits. For complete defi
- `::Identifier` - Marks identifiers - `::Identifier` - Marks identifiers
- `::Implementable` - Meta-trait for defining language constructs (trait, impl, inher) - `::Implementable` - Meta-trait for defining language constructs (trait, impl, inher)
> **Complete Reference**: See Appendix B for full trait definitions with all methods, examples, and implementation details. > **Complete Reference**: See [Appendix B](./complete_trait_reference.html) for full trait definitions with all methods, examples, and implementation details.
--- ---
@ -1349,7 +1349,7 @@ When inheriting from generic traits, you must either:
(Multiplyable -- Multiplyable) { dup * } ::square fn (Multiplyable -- Multiplyable) { dup * } ::square fn
``` ```
> **Future Enhancement**: See Appendix F for planned type parameter enforcement at parse time. > **Future Enhancement**: See [Appendix F](./memory_management.html) for planned type parameter enforcement at parse time.
--- ---
@ -1456,7 +1456,7 @@ The standard library provides I/O, string operations, type conversions, and util
- Combinators: `map`, `filter`, `reduce`, `each` - Combinators: `map`, `filter`, `reduce`, `each`
- Manipulation: `concat`, `reverse`, `transpose`, `window` - Manipulation: `concat`, `reverse`, `transpose`, `window`
> **Complete Reference**: See Appendix A for the full standard library reference with all functions, signatures, and examples. > **Complete Reference**: See [Appendix A](./standard_library.html) for the full standard library reference with all functions, signatures, and examples.
--- ---
@ -1466,15 +1466,15 @@ This appendix provides a complete alphabetical reference of all standard library
### Standard Library Categories ### Standard Library Categories
**Array Operations**: at, concat, each, filter, length, map, reduce, reverse, shape, slice, transpose, window **Array Operations**: [at](#at), [concat](#concat), [each](#each), [filter](#filter), [length](#length), [map](#map), [reduce](#reduce), [reverse](#reverse), [shape](#shape), [slice](#slice), [transpose](#transpose), [window](#window)
**I/O Operations**: input, print, read, write **I/O Operations**: [at](#at), [concat](#concat), [each](#each), [filter](#filter)
**String Operations**: concat, join, length, split, substr **String Operations**: [length](#length), [map](#map) [reduce](#reduce), [reverse](#reverse), [shape](#shape)
**Type Conversion**: parse, to_i8, to_i16, to_i32, to_i64, to_u8, to_u16, to_u32, to_u64, to_f32, to_f64, to_str **Type Conversion**: [slice](#slice), [to_i8, to_i16, to_i32, to_i64](#to_i8-to_i16-to_i32-to_i64), [to_u8, to_u16, to_u32, to_u64](#to_u8-to_u16-to_u32-to_u64), [to_f32, to_f64](#to_f32-to_f64), [to_str](#to_str)
**Utility Operations**: eval, lambda **Utility Operations**: [transpose](#transpose), [window](#window)
### Alphabetical Reference ### Alphabetical Reference
@ -1486,7 +1486,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
[10 20 30] 1 at // Returns 20 [10 20 30] 1 at // Returns 20
``` ```
**See Also**: slice, length **See Also**: [slice](#slice), [length](#length)
#### concat #### concat
**Signature**: `(Concatenable Concatenable -- Concatenable)` **Signature**: `(Concatenable Concatenable -- Concatenable)`
@ -1497,7 +1497,7 @@ This appendix provides a complete alphabetical reference of all standard library
[1 2 3] [4 5 6] concat // Returns [1 2 3 4 5 6] [1 2 3] [4 5 6] concat // Returns [1 2 3 4 5 6]
"hello" " world" concat // Returns "hello world" "hello" " world" concat // Returns "hello world"
``` ```
**See Also**: join, split **See Also**: [join](#join), [split](#split)
#### depth #### depth
**Signature**: `(-- Size)` **Signature**: `(-- Size)`
@ -1507,7 +1507,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
1 2 3 depth // Returns 1 2 3 3 1 2 3 depth // Returns 1 2 3 3
``` ```
**See Also**: pick, roll **See Also**: [pick](#pick), [roll](#roll)
#### drop #### drop
**Signature**: `(Self --)` **Signature**: `(Self --)`
@ -1517,7 +1517,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
5 10 drop // Returns 5 5 10 drop // Returns 5
``` ```
**See Also**: dup, swap **See Also**: [dup](#dup), [swap](#swap)
#### dup #### dup
**Signature**: `(Self -- Self Self)` **Signature**: `(Self -- Self Self)`
@ -1527,7 +1527,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
5 dup // Returns 5 5 5 dup // Returns 5 5
``` ```
**See Also**: drop, over **See Also**: [drop](#drop), [over](#over)
#### each #### each
**Signature**: `(ArrayOf<T> TokenString --)` **Signature**: `(ArrayOf<T> TokenString --)`
@ -1536,7 +1536,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
[1 2 3] { print } each // Prints 1, 2, 3 [1 2 3] { print } each // Prints 1, 2, 3
``` ```
**See Also**: map, filter **See Also**: [map](#map), [filter](#filter)
#### eval #### eval
**Signature**: `(TokenString --)` **Signature**: `(TokenString --)`
@ -1546,7 +1546,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
"2 3 +" eval // Returns 5 "2 3 +" eval // Returns 5
``` ```
**See Also**: lambda **See Also**: [lambda](#lambda)
#### filter #### filter
**Signature**: `(ArrayOf<T> TokenString -- ArrayOf<T>)` **Signature**: `(ArrayOf<T> TokenString -- ArrayOf<T>)`
@ -1555,7 +1555,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
[1 2 3 4 5] { 2 % 0 == } filter // Returns [2 4] [1 2 3 4 5] { 2 % 0 == } filter // Returns [2 4]
``` ```
**See Also**: map, reduce **See Also**: [map](#map), [reduce](#reduce)
#### input #### input
**Signature**: `(String -- String)` **Signature**: `(String -- String)`
@ -1564,7 +1564,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
"Enter name: " input // Prompts and returns user input "Enter name: " input // Prompts and returns user input
``` ```
**See Also**: print, read **See Also**: [print](#print), [read](#read)
#### join #### join
**Signature**: `(ArrayOf<String> String -- String)` **Signature**: `(ArrayOf<String> String -- String)`
@ -1573,7 +1573,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
["a" "b" "c"] "," join // Returns "a,b,c" ["a" "b" "c"] "," join // Returns "a,b,c"
``` ```
**See Also**: split, concat **See Also**: [split](#split), [concat](#concat)
#### lambda #### lambda
**Signature**: `(TokenString -- Callable)` **Signature**: `(TokenString -- Callable)`
@ -1584,7 +1584,7 @@ This appendix provides a complete alphabetical reference of all standard library
{ dup * } lambda ::square swap { dup * } lambda ::square swap
5 square eval // Returns 25 5 square eval // Returns 25
``` ```
**See Also**: eval **See Also**: [eval](#eval)
#### length #### length
**Signature**: `(Sized -- i64)` **Signature**: `(Sized -- i64)`
@ -1595,7 +1595,7 @@ This appendix provides a complete alphabetical reference of all standard library
[1 2 3 4 5] length // Returns 5 [1 2 3 4 5] length // Returns 5
"hello" length // Returns 5 "hello" length // Returns 5
``` ```
**See Also**: at, slice **See Also**: [at](#at), [slice](#slice)
#### map #### map
**Signature**: `(ArrayOf<T> TokenString -- ArrayOf<U>)` **Signature**: `(ArrayOf<T> TokenString -- ArrayOf<U>)`
@ -1604,7 +1604,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
[1 2 3 4] { 2 * } map // Returns [2 4 6 8] [1 2 3 4] { 2 * } map // Returns [2 4 6 8]
``` ```
**See Also**: filter, reduce, each **See Also**: [filter](#filter), [reduce](#reduce), [each](#each)
#### over #### over
**Signature**: `(Self Self -- Self Self Self)` **Signature**: `(Self Self -- Self Self Self)`
@ -1614,7 +1614,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
5 10 over // Returns 5 10 5 5 10 over // Returns 5 10 5
``` ```
**See Also**: dup, swap, rot **See Also**: [dup](#dup), [swap](#swap), [rot](#rot)
#### parse #### parse
**Signature**: `(String -- Parseable)` **Signature**: `(String -- Parseable)`
@ -1624,7 +1624,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
"123" parse // Returns 123 (as appropriate numeric type) "123" parse // Returns 123 (as appropriate numeric type)
``` ```
**See Also**: to_str **See Also**: [to_str](#to_str)
#### pick #### pick
**Signature**: `(Size -- Self)` **Signature**: `(Size -- Self)`
@ -1634,7 +1634,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
1 2 3 4 2 pick // Returns 1 2 3 4 2 1 2 3 4 2 pick // Returns 1 2 3 4 2
``` ```
**See Also**: roll, depth **See Also**: [roll](#roll), [depth](#depth)
#### print #### print
**Signature**: `(Stringifiable --)` **Signature**: `(Stringifiable --)`
@ -1644,7 +1644,7 @@ This appendix provides a complete alphabetical reference of all standard library
"Hello" print // Prints: Hello "Hello" print // Prints: Hello
42 print // Prints: 42 42 print // Prints: 42
``` ```
**See Also**: input, to_str **See Also**: [input](#input), [to_str](#to_str)
#### read #### read
**Signature**: `(String -- String)` **Signature**: `(String -- String)`
@ -1653,7 +1653,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
"file.txt" read // Returns file contents "file.txt" read // Returns file contents
``` ```
**See Also**: write **See Also**: [write](#write)
#### reduce #### reduce
**Signature**: `(ArrayOf<T> T TokenString -- T)` **Signature**: `(ArrayOf<T> T TokenString -- T)`
@ -1662,7 +1662,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
[1 2 3 4] 0 { + } reduce // Returns 10 [1 2 3 4] 0 { + } reduce // Returns 10
``` ```
**See Also**: map, filter **See Also**: [map](#map), [filter](#filter)
#### reverse #### reverse
**Signature**: `(ArrayOf<T> -- ArrayOf<T>)` **Signature**: `(ArrayOf<T> -- ArrayOf<T>)`
@ -1671,7 +1671,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
[1 2 3] reverse // Returns [3 2 1] [1 2 3] reverse // Returns [3 2 1]
``` ```
**See Also**: transpose **See Also**: [transpose](#transpose)
#### roll #### roll
**Signature**: `(Size Size --)` **Signature**: `(Size Size --)`
@ -1681,7 +1681,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
1 2 3 4 3 1 roll // Rotates top 3 once: 1 3 4 2 1 2 3 4 3 1 roll // Rotates top 3 once: 1 3 4 2
``` ```
**See Also**: rot, pick **See Also**: [rot](#rot), [pick](#pick)
#### rot #### rot
**Signature**: `(Self Self Self -- Self Self Self)` **Signature**: `(Self Self Self -- Self Self Self)`
@ -1691,7 +1691,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
1 2 3 rot // Returns 2 3 1 1 2 3 rot // Returns 2 3 1
``` ```
**See Also**: swap, roll **See Also**: [swap](#swap), [roll](#roll)
#### slice #### slice
**Signature**: `(Sliceable Size Size -- Sliceable)` **Signature**: `(Sliceable Size Size -- Sliceable)`
@ -1701,7 +1701,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
[10 20 30 40] 1 3 slice // Returns [20 30] [10 20 30 40] 1 3 slice // Returns [20 30]
``` ```
**See Also**: at, length **See Also**: [at](#at), [length](#length)
#### split #### split
**Signature**: `(String String -- ArrayOf<String>)` **Signature**: `(String String -- ArrayOf<String>)`
@ -1711,7 +1711,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
"a,b,c" "," split // Returns ["a" "b" "c"] "a,b,c" "," split // Returns ["a" "b" "c"]
``` ```
**See Also**: join, substr **See Also**: [join](#join), [substr](#substr)
#### substr #### substr
**Signature**: `(String Size Size -- String)` **Signature**: `(String Size Size -- String)`
@ -1721,7 +1721,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
"hello" 1 3 substr // Returns "el" "hello" 1 3 substr // Returns "el"
``` ```
**See Also**: slice, split **See Also**: [slice](#slice), [split](#split)
#### swap #### swap
**Signature**: `(Self Self -- Self Self)` **Signature**: `(Self Self -- Self Self)`
@ -1731,7 +1731,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
5 10 swap // Returns 10 5 5 10 swap // Returns 10 5
``` ```
**See Also**: dup, rot **See Also**: [dup](#dup), [rot](#rot)
#### to_f32, to_f64 #### to_f32, to_f64
**Signature**: `(Convertible -- f32/f64)` **Signature**: `(Convertible -- f32/f64)`
@ -1741,7 +1741,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
42 to_f64 // Returns 42.0 42 to_f64 // Returns 42.0
``` ```
**See Also**: to_i32, to_str **See Also**: [to_i8, to_i16, to_i32, to_i64](#to_i8-to_i16-to_i32-to_i64), [to_u8, to_u16, to_u32, to_u64](#to_u8-to_u16-to_u32-to_u64)
#### to_i8, to_i16, to_i32, to_i64 #### to_i8, to_i16, to_i32, to_i64
**Signature**: `(Convertible -- i8/i16/i32/i64)` **Signature**: `(Convertible -- i8/i16/i32/i64)`
@ -1751,7 +1751,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
3.14 to_i32 // Returns 3 (truncates) 3.14 to_i32 // Returns 3 (truncates)
``` ```
**See Also**: to_u32, to_f64 **See Also**: [to_u8, to_u16, to_u32, to_u64](#to_u8-to_u16-to_u32-to_u64), [to_f32, to_f64](#to_f32-to_f64)
#### to_str #### to_str
**Signature**: `(Stringifiable -- String)` **Signature**: `(Stringifiable -- String)`
@ -1761,7 +1761,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
42 to_str // Returns "42" 42 to_str // Returns "42"
``` ```
**See Also**: parse, print **See Also**: [parse](#parse), [print](#print)
#### to_u8, to_u16, to_u32, to_u64 #### to_u8, to_u16, to_u32, to_u64
**Signature**: `(Convertible -- u8/u16/u32/u64)` **Signature**: `(Convertible -- u8/u16/u32/u64)`
@ -1771,7 +1771,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
42 to_u32 // Returns 42 (as u32) 42 to_u32 // Returns 42 (as u32)
``` ```
**See Also**: to_i32, to_f64 **See Also**: [to_i8, to_i16, to_i32, to_i64](#to_i8-to_i16-to_i32-to_i64), [to_f32, to_f64](#to_f32-to_f64)
#### transpose #### transpose
**Signature**: `(ArrayOf<ArrayOf<T>> -- ArrayOf<ArrayOf<T>>)` **Signature**: `(ArrayOf<ArrayOf<T>> -- ArrayOf<ArrayOf<T>>)`
@ -1780,7 +1780,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
[[1 2] [3 4]] transpose // Returns [[1 3] [2 4]] [[1 2] [3 4]] transpose // Returns [[1 3] [2 4]]
``` ```
**See Also**: reverse **See Also**: [reverse](#reverse)
#### window #### window
**Signature**: `(ArrayOf<T> Size -- ArrayOf<ArrayOf<T>>)` **Signature**: `(ArrayOf<T> Size -- ArrayOf<ArrayOf<T>>)`
@ -1789,7 +1789,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
[1 2 3 4] 2 window // Returns [[1 2] [2 3] [3 4]] [1 2 3 4] 2 window // Returns [[1 2] [2 3] [3 4]]
``` ```
**See Also**: slice **See Also**: [slice](#slice)
#### write #### write
**Signature**: `(String String --)` **Signature**: `(String String --)`
@ -1798,7 +1798,7 @@ This appendix provides a complete alphabetical reference of all standard library
``` ```
"data" "file.txt" write // Writes "data" to file.txt "data" "file.txt" write // Writes "data" to file.txt
``` ```
**See Also**: read **See Also**: [read](#read)
--- ---
@ -3781,5 +3781,3 @@ dup ::x get print // Prints: 3.0
``` ```
--- ---
**End of Stack Language Specification v0.8**