diff --git a/docs/api/safeds/data/tabular/containers/Column.md b/docs/api/safeds/data/tabular/containers/Column.md index 9d336f57b..46ba5c304 100644 --- a/docs/api/safeds/data/tabular/containers/Column.md +++ b/docs/api/safeds/data/tabular/containers/Column.md @@ -57,7 +57,7 @@ pipeline example { */ attr type: DataType - /* + /** * Return the distinct values in the column. * * @param ignoreMissingValues Whether to ignore missing values. @@ -915,17 +915,29 @@ pipeline example { ## `getDistinctValues` {#safeds.data.tabular.containers.Column.getDistinctValues data-toc-label='[function] getDistinctValues'} +Return the distinct values in the column. + **Parameters:** | Name | Type | Description | Default | |------|------|-------------|---------| -| `ignoreMissingValues` | [`Boolean`][safeds.lang.Boolean] | - | `#!sds true` | +| `ignoreMissingValues` | [`Boolean`][safeds.lang.Boolean] | Whether to ignore missing values. | `#!sds true` | **Results:** | Name | Type | Description | |------|------|-------------| -| `distinctValues` | [`List`][safeds.lang.List] | - | +| `distinctValues` | [`List`][safeds.lang.List] | The distinct values in the column. | + +**Examples:** + +```sds hl_lines="3" +pipeline example { + val column = Column("test", [1, 2, 3, 2]); + val result = column.getDistinctValues(); + // [1, 2, 3] +} +``` ??? quote "Stub code in `Column.sdsstub`" diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 054211c55..de789bf1d 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -25,6 +25,7 @@ nav: - pipeline-language/statements/README.md - Expression Statements: pipeline-language/statements/expression-statements.md - Assignments: pipeline-language/statements/assignments.md + - Output Statements: pipeline-language/statements/output-statements.md - Expressions: - pipeline-language/expressions/README.md - Literals: pipeline-language/expressions/literals.md diff --git a/docs/pipeline-language/statements/README.md b/docs/pipeline-language/statements/README.md index fde4b1fa7..e6f046952 100644 --- a/docs/pipeline-language/statements/README.md +++ b/docs/pipeline-language/statements/README.md @@ -1,14 +1,16 @@ # Statements -Statements are used to run some action. Safe-DS has only two type of statements: +Statements are used to run some action. Safe-DS only has three type of statements: - [Expression statements][expression-statements] evaluate an [expression][expressions] and discard any results. They are only useful if the expression has side effects, such as writing to a file. - [Assignments][assignments] also evaluate an [expression][expressions], but then store results in [placeholders][placeholders]. This allows reusing the results multiple times without having to recompute them. +- [Output statements][output-statements] evaluate an [expression][expressions] as well, and provide options to inspect + its results. Unlike when using assignments, the result cannot be reused. - -[assignments]: ./assignments.md -[expression-statements]: ./expression-statements.md +[assignments]: assignments.md +[expression-statements]: expression-statements.md +[output-statements]: output-statements.md [expressions]: ../expressions/README.md -[placeholders]: ./assignments.md#declaring-placeholders +[placeholders]: assignments.md#declaring-placeholders diff --git a/docs/pipeline-language/statements/assignments.md b/docs/pipeline-language/statements/assignments.md index e4112e395..6081be4f1 100644 --- a/docs/pipeline-language/statements/assignments.md +++ b/docs/pipeline-language/statements/assignments.md @@ -27,14 +27,15 @@ This assignment to a placeholder has the following syntactic elements: - The name of the placeholder, here `titanic`. It can be any combination of lower- and uppercase letters, underscores, and numbers, as long as it does not start with a number. - An `#!sds =` sign. -- The expression to evaluate (right-hand side). +- The [expression][expressions] to evaluate (right-hand side). - A semicolon at the end. ??? info "Name convention" Use `#!sds lowerCamelCase` for the name of the placeholder. You may prefix the name of an unused placeholder with an underscore (`_`) to indicate that it is intentionally unused, e.g. to - [inspect its value](#inspecting-placeholder-values-in-vs-code). This disables the "unused" warning. + [inspect its value](#inspecting-placeholder-values-in-vs-code). This disables the "unused" warning. For value + inspection, also consider using an [output statement][output-statements] instead. ### References to Placeholder @@ -104,6 +105,7 @@ such cases. [expressions]: ../expressions/README.md [expression-statements]: expression-statements.md [installation]: ../../getting-started/installation.md +[output-statements]: output-statements.md [references]: ../expressions/references.md#references [runner]: https://github.com/Safe-DS/Runner [results]: ../segments.md#results diff --git a/docs/pipeline-language/statements/output-statements.md b/docs/pipeline-language/statements/output-statements.md new file mode 100644 index 000000000..dc7d7465e --- /dev/null +++ b/docs/pipeline-language/statements/output-statements.md @@ -0,0 +1,26 @@ +# Output Statements + +Output statements are used to evaluate an expression and inspect its results. Unlike when using assignments, the results +cannot be reused. However, it is also not necessary to think of unique names for placeholders, which saves time and +keeps the namespace clean. + +The next snippet shows how the singular result of an expression (the loaded +[`Table`][safeds.data.tabular.containers.Table]) can be inspected: + +```sds +out Table.fromCsvFile("titanic.csv"); +``` + +This output statement has the following syntactic elements: + +- The keyword `#!sds out`, which indicates that we want to inspect the results of an expression. +- The expression to evaluate. +- A semicolon at the end. + +Inspecting values requires a working installation of the [Safe-DS Runner][runner]. Follow the instructions in the +[installation guide][installation] to install it. Afterward, you can inspect values of various types via +_code lenses_ in the editor, as explained for [assignments][value-inspection]. + +[installation]: ../../getting-started/installation.md +[runner]: https://github.com/Safe-DS/Runner +[value-inspection]: assignments.md#inspecting-placeholder-values-in-vs-code diff --git a/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Column.sdsstub b/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Column.sdsstub index d0ab3d850..f67f95904 100644 --- a/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Column.sdsstub +++ b/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Column.sdsstub @@ -44,7 +44,7 @@ class Column( */ attr type: DataType - /* + /** * Return the distinct values in the column. * * @param ignoreMissingValues Whether to ignore missing values.