ARTICLE: "columns" "Column sequences"
"A " { $emphasis "column" } " presents a column of a matrix represented as a sequence of rows:"
{ $subsection column }
-{ $subsection <column> } ;
+{ $subsection <column> }
+"A utility word:"
+{ $subsection flipped } ;
HELP: column
{ $class-description "A virtual sequence which presents a fixed column of a matrix represented as a sequence of rows. New instances can be created by calling " { $link <column> } "." } ;
"In the same sense that " { $link <reversed> } " is a virtual variant of " { $link reverse } ", " { $link <column> } " is a virtual variant of " { $snippet "swap [ nth ] curry map" } "."
} ;
+HELP: <flipped>
+{ $values { "seq" sequence } { "seq'" sequence } }
+{ $description "Outputs a new virtual sequence which presents the transpose of " { $snippet "seq" } "." }
+{ $notes "This is the virtual sequence equivalent of " { $link flip } "." } ;
+
ABOUT: "columns"
M: column length seq>> length ;
INSTANCE: column virtual-sequence
+
+: <flipped> ( seq -- seq' )
+ dup first length [ <column> ] with map ;