Add columns vocab
parent
851c54ea7a
commit
c564481cc5
|
@ -0,0 +1,2 @@
|
|||
Slava Pestov
|
||||
Daniel Ehrenberg
|
|
@ -0,0 +1,26 @@
|
|||
USING: help.markup help.syntax sequences ;
|
||||
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> } ;
|
||||
|
||||
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> } "." } ;
|
||||
|
||||
HELP: <column> ( seq n -- column )
|
||||
{ $values { "seq" sequence } { "n" "a non-negative integer" } { "column" column } }
|
||||
{ $description "Outputs a new virtual sequence which presents a fixed column of a matrix represented as a sequence of rows." "The " { $snippet "i" } "th element of a column is the " { $snippet "n" } "th element of the " { $snippet "i" } "th element of" { $snippet "seq" } ". Every element of " { $snippet "seq" } " must be a sequence, and all sequences must have equal length." }
|
||||
{ $examples
|
||||
{ $example
|
||||
"USING: arrays prettyprint sequences ;"
|
||||
"{ { 1 2 3 } { 4 5 6 } { 7 8 9 } } 0 <column> >array ."
|
||||
"{ 1 4 7 }"
|
||||
}
|
||||
}
|
||||
{ $notes
|
||||
"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" } "."
|
||||
} ;
|
||||
|
||||
ABOUT: "columns"
|
|
@ -0,0 +1,9 @@
|
|||
IN: columns.tests
|
||||
USING: columns sequences kernel namespaces arrays tools.test math ;
|
||||
|
||||
! Columns
|
||||
{ { 1 2 3 } { 4 5 6 } { 7 8 9 } } [ clone ] map "seq" set
|
||||
|
||||
[ { 1 4 7 } ] [ "seq" get 0 <column> >array ] unit-test
|
||||
[ ] [ "seq" get 1 <column> [ sq ] change-each ] unit-test
|
||||
[ { 4 25 64 } ] [ "seq" get 1 <column> >array ] unit-test
|
|
@ -0,0 +1,15 @@
|
|||
! Copyright (C) 2005, 2008 Slava Pestov, Daniel Ehrenberg.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: sequences kernel accessors ;
|
||||
IN: columns
|
||||
|
||||
! A column of a matrix
|
||||
TUPLE: column seq col ;
|
||||
|
||||
C: <column> column
|
||||
|
||||
M: column virtual-seq seq>> ;
|
||||
M: column virtual@ dup col>> -rot seq>> nth bounds-check ;
|
||||
M: column length seq>> length ;
|
||||
|
||||
INSTANCE: column virtual-sequence
|
|
@ -0,0 +1 @@
|
|||
Virtual sequence view of a matrix column
|
|
@ -0,0 +1 @@
|
|||
collections
|
Loading…
Reference in New Issue