]> gitweb.factorcode.org Git - factor.git/commitdiff
Add <flipped> word
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 14 Aug 2008 00:47:19 +0000 (19:47 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 14 Aug 2008 00:47:19 +0000 (19:47 -0500)
basis/columns/columns-docs.factor
basis/columns/columns.factor

index a5b26e3fd017186e34be40dad175a6b14633b1cd..e0d4e4a2e02346c97c97e58637788bcc7ab8a6fb 100644 (file)
@@ -4,7 +4,9 @@ IN: columns
 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> } "." } ;
@@ -23,4 +25,9 @@ HELP: <column> ( seq n -- 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"
index 7e4a7fd408447238619aa8e53dd28df078c06946..9e282a0b641399448e2d2992720fc7c248f6f91e 100644 (file)
@@ -13,3 +13,6 @@ M: column virtual@ dup col>> -rot seq>> nth bounds-check ;
 M: column length seq>> length ;
 
 INSTANCE: column virtual-sequence
+
+: <flipped> ( seq -- seq' )
+    dup first length [ <column> ] with map ;