Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Flatten

Usage in Essence

With one argument, flatten(M) returns a one-dimensional matrix containing all the elements of the input matrix.

With two arguments, flatten(n,M) the first n+1 dimensions are flattened into one dimension.

Warning

flatten(n,M) has not yet been implemented.

Expression variant

The Flatten variant of Expression in the AST has structure defined as:

Flatten(Metadata, Option<Moo<Expression>>, Moo<Expression>)

The return type and domain of Flatten is a matrix of the innermost elements of the flattened matrix’s return type or domain. This has not yet been implemented in the case where the dimensions to flatten are provided.

flatten rule

The flatten rule in crates/conjure-cp-rules/src/matrix/flatten.rs turns flatten expressions containing atomic matrix expressions into a flat matrix literal.