diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index f1e41ac2b6..061866fe3e 100755 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -58,16 +58,13 @@ num-types get f builtins set "alien.accessors" "arrays" "bit-arrays" - "bit-vectors" "byte-arrays" - "byte-vectors" "classes.private" "classes.tuple" "classes.tuple.private" "compiler.units" "continuations.private" "float-arrays" - "float-vectors" "generator" "growable" "hashtables" @@ -455,54 +452,6 @@ tuple } } define-tuple-class -"byte-vector" "byte-vectors" create -tuple -{ - { - { "byte-array" "byte-arrays" } - "underlying" - { "underlying" "growable" } - { "set-underlying" "growable" } - } { - { "array-capacity" "sequences.private" } - "fill" - { "length" "sequences" } - { "set-fill" "growable" } - } -} define-tuple-class - -"bit-vector" "bit-vectors" create -tuple -{ - { - { "bit-array" "bit-arrays" } - "underlying" - { "underlying" "growable" } - { "set-underlying" "growable" } - } { - { "array-capacity" "sequences.private" } - "fill" - { "length" "sequences" } - { "set-fill" "growable" } - } -} define-tuple-class - -"float-vector" "float-vectors" create -tuple -{ - { - { "float-array" "float-arrays" } - "underlying" - { "underlying" "growable" } - { "set-underlying" "growable" } - } { - { "array-capacity" "sequences.private" } - "fill" - { "length" "sequences" } - { "set-fill" "growable" } - } -} define-tuple-class - "curry" "kernel" create tuple { diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor index 4d5f31dc82..4b74804749 100755 --- a/core/bootstrap/syntax.factor +++ b/core/bootstrap/syntax.factor @@ -14,16 +14,13 @@ IN: bootstrap.syntax ";" "pprint-sequence ( obj -- seq ) M: object >pprint-sequence ; M: vector >pprint-sequence ; -M: bit-vector >pprint-sequence ; -M: byte-vector >pprint-sequence ; -M: float-vector >pprint-sequence ; M: curry >pprint-sequence ; M: compose >pprint-sequence ; M: hashtable >pprint-sequence >alist ; diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index bb3dc9337e..0dea0f43d9 100755 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -76,10 +76,7 @@ ARTICLE: "sequences-reshape" "Reshaping sequences" { $subsection reversed } { $subsection } "Transposing a matrix:" -{ $subsection flip } -"A " { $emphasis "column" } " presents a column of a matrix represented as a sequence of rows:" -{ $subsection column } -{ $subsection } ; +{ $subsection flip } ; ARTICLE: "sequences-appending" "Appending sequences" { $subsection append } @@ -785,23 +782,6 @@ HELP: { subseq } related-words -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 } "." } ; - -HELP: ( 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 >array ." - "{ 1 4 7 }" - } -} -{ $notes - "In the same sense that " { $link } " is a virtual variant of " { $link reverse } ", " { $link } " is a virtual variant of " { $snippet "swap [ nth ] curry map" } "." -} ; - HELP: repetition { $class-description "A virtual sequence consisting of " { $link repetition-elt } " repeated " { $link repetition-len } " times. Repetitions are created by calling " { $link } "." } ; diff --git a/core/sequences/sequences-tests.factor b/core/sequences/sequences-tests.factor index e8db18b3d0..100184798c 100755 --- a/core/sequences/sequences-tests.factor +++ b/core/sequences/sequences-tests.factor @@ -224,13 +224,6 @@ unit-test [ V{ 1 2 3 } ] [ 3 V{ 1 3 2 } clone [ push-new ] keep ] unit-test -! Columns -{ { 1 2 3 } { 4 5 6 } { 7 8 9 } } [ clone ] map "seq" set - -[ { 1 4 7 } ] [ "seq" get 0 >array ] unit-test -[ ] [ "seq" get 1 [ sq ] change-each ] unit-test -[ { 4 25 64 } ] [ "seq" get 1 >array ] unit-test - ! erg's random tester found this one [ SBUF" 12341234" ] [ 9 dup "1234" swap push-all dup dup swap push-all diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 252df54391..924d9a05cb 100755 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -215,18 +215,6 @@ M: slice length dup slice-to swap slice-from - ; INSTANCE: slice virtual-sequence -! A column of a matrix -TUPLE: column seq col ; - -C: column - -M: column virtual-seq column-seq ; -M: column virtual@ - dup column-col -rot column-seq nth bounds-check ; -M: column length column-seq length ; - -INSTANCE: column virtual-sequence - ! One element repeated many times TUPLE: repetition len elt ; @@ -703,5 +691,5 @@ PRIVATE> : flip ( matrix -- newmatrix ) dup empty? [ dup [ length ] map infimum - [ dup like ] with map + swap [ [ nth-unsafe ] with { } map-as ] curry { } map-as ] unless ; diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor index c2eb411f0a..a2d15d2981 100755 --- a/core/syntax/syntax-docs.factor +++ b/core/syntax/syntax-docs.factor @@ -150,18 +150,6 @@ ARTICLE: "syntax-byte-arrays" "Byte array syntax" { $subsection POSTPONE: B{ } "Byte arrays are documented in " { $link "byte-arrays" } "." ; -ARTICLE: "syntax-bit-vectors" "Bit vector syntax" -{ $subsection POSTPONE: ?V{ } -"Bit vectors are documented in " { $link "bit-vectors" } "." ; - -ARTICLE: "syntax-float-vectors" "Float vector syntax" -{ $subsection POSTPONE: FV{ } -"Float vectors are documented in " { $link "float-vectors" } "." ; - -ARTICLE: "syntax-byte-vectors" "Byte vector syntax" -{ $subsection POSTPONE: BV{ } -"Byte vectors are documented in " { $link "byte-vectors" } "." ; - ARTICLE: "syntax-pathnames" "Pathname syntax" { $subsection POSTPONE: P" } "Pathnames are documented in " { $link "pathnames" } "." ; @@ -182,9 +170,6 @@ $nl { $subsection "syntax-float-arrays" } { $subsection "syntax-vectors" } { $subsection "syntax-sbufs" } -{ $subsection "syntax-bit-vectors" } -{ $subsection "syntax-byte-vectors" } -{ $subsection "syntax-float-vectors" } { $subsection "syntax-hashtables" } { $subsection "syntax-tuples" } { $subsection "syntax-pathnames" } ; @@ -291,30 +276,12 @@ HELP: B{ { $description "Marks the beginning of a literal byte array. Literal byte arrays are terminated by " { $link POSTPONE: } } "." } { $examples { $code "B{ 1 2 3 }" } } ; -HELP: BV{ -{ $syntax "BV{ elements... }" } -{ $values { "elements" "a list of bytes" } } -{ $description "Marks the beginning of a literal byte vector. Literal byte vectors are terminated by " { $link POSTPONE: } } "." } -{ $examples { $code "BV{ 1 2 3 12 }" } } ; - HELP: ?{ { $syntax "?{ elements... }" } { $values { "elements" "a list of booleans" } } { $description "Marks the beginning of a literal bit array. Literal bit arrays are terminated by " { $link POSTPONE: } } "." } { $examples { $code "?{ t f t }" } } ; -HELP: ?V{ -{ $syntax "?V{ elements... }" } -{ $values { "elements" "a list of booleans" } } -{ $description "Marks the beginning of a literal bit vector. Literal bit vectors are terminated by " { $link POSTPONE: } } "." } -{ $examples { $code "?V{ t f t }" } } ; - -HELP: FV{ -{ $syntax "FV{ elements... }" } -{ $values { "elements" "a list of real numbers" } } -{ $description "Marks the beginning of a literal float vector. Literal float vectors are terminated by " { $link POSTPONE: } } "." } -{ $examples { $code "FV{ 1.0 2.0 3.0 }" } } ; - HELP: F{ { $syntax "F{ elements... }" } { $values { "elements" "a list of real numbers" } } diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index eaf5ffea05..566f5471f4 100755 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien arrays bit-arrays bit-vectors byte-arrays -byte-vectors definitions generic hashtables kernel math +USING: alien arrays bit-arrays byte-arrays +definitions generic hashtables kernel math namespaces parser sequences strings sbufs vectors words quotations io assocs splitting classes.tuple generic.standard -generic.math classes io.files vocabs float-arrays float-vectors +generic.math classes io.files vocabs float-arrays classes.union classes.mixin classes.predicate classes.singleton compiler.units combinators debugger ; IN: bootstrap.syntax @@ -79,11 +79,8 @@ IN: bootstrap.syntax "{" [ \ } [ >array ] parse-literal ] define-syntax "V{" [ \ } [ >vector ] parse-literal ] define-syntax "B{" [ \ } [ >byte-array ] parse-literal ] define-syntax - "BV{" [ \ } [ >byte-vector ] parse-literal ] define-syntax "?{" [ \ } [ >bit-array ] parse-literal ] define-syntax - "?V{" [ \ } [ >bit-vector ] parse-literal ] define-syntax "F{" [ \ } [ >float-array ] parse-literal ] define-syntax - "FV{" [ \ } [ >float-vector ] parse-literal ] define-syntax "H{" [ \ } [ >hashtable ] parse-literal ] define-syntax "T{" [ \ } [ >tuple ] parse-literal ] define-syntax "W{" [ \ } [ first ] parse-literal ] define-syntax diff --git a/extra/benchmark/dispatch2/dispatch2.factor b/extra/benchmark/dispatch2/dispatch2.factor index d51a723cbd..53e9c9a14c 100644 --- a/extra/benchmark/dispatch2/dispatch2.factor +++ b/extra/benchmark/dispatch2/dispatch2.factor @@ -1,4 +1,4 @@ -USING: namespaces math sequences splitting kernel ; +USING: namespaces math sequences splitting kernel columns ; IN: benchmark.dispatch2 : sequences diff --git a/extra/benchmark/dispatch3/dispatch3.factor b/extra/benchmark/dispatch3/dispatch3.factor index bb4c5ba904..409d6d4a0f 100644 --- a/extra/benchmark/dispatch3/dispatch3.factor +++ b/extra/benchmark/dispatch3/dispatch3.factor @@ -1,5 +1,5 @@ USING: sequences math mirrors splitting kernel namespaces -assocs alien.syntax ; +assocs alien.syntax columns ; IN: benchmark.dispatch3 GENERIC: g ( obj -- str ) diff --git a/extra/benchmark/spectral-norm/spectral-norm.factor b/extra/benchmark/spectral-norm/spectral-norm.factor index 7eddeefc1b..2c7dc1e80d 100644 --- a/extra/benchmark/spectral-norm/spectral-norm.factor +++ b/extra/benchmark/spectral-norm/spectral-norm.factor @@ -19,7 +19,7 @@ IN: benchmark.spectral-norm pick 0.0 [ swap >r >r 2dup r> (eval-A-times-u) r> + ] reduce nip - ] F{ } map-as 2nip ; inline + ] F{ } map-as { float-array } declare 2nip ; inline : (eval-At-times-u) ( u i j -- x ) tuck swap eval-A >r swap nth-unsafe r> * ; inline @@ -29,7 +29,7 @@ IN: benchmark.spectral-norm pick 0.0 [ swap >r >r 2dup r> (eval-At-times-u) r> + ] reduce nip - ] F{ } map-as 2nip ; inline + ] F{ } map-as { float-array } declare 2nip ; inline : eval-AtA-times-u ( n u -- seq ) dupd eval-A-times-u eval-At-times-u ; inline diff --git a/core/bit-vectors/bit-vectors-docs.factor b/extra/bit-vectors/bit-vectors-docs.factor similarity index 82% rename from core/bit-vectors/bit-vectors-docs.factor rename to extra/bit-vectors/bit-vectors-docs.factor index f2f5c4da2c..9ceb2df342 100755 --- a/core/bit-vectors/bit-vectors-docs.factor +++ b/extra/bit-vectors/bit-vectors-docs.factor @@ -11,6 +11,8 @@ $nl "Creating bit vectors:" { $subsection >bit-vector } { $subsection } +"Literal syntax:" +{ $subsection POSTPONE: ?V{ } "If you don't care about initial capacity, a more elegant way to create a new bit vector is to write:" { $code "?V{ } clone" } ; @@ -31,3 +33,10 @@ HELP: bit-array>vector { $values { "bit-array" "an array" } { "length" "a non-negative integer" } { "bit-vector" bit-vector } } { $description "Creates a new bit vector using the array for underlying storage with the specified initial length." } { $warning "This word is in the " { $vocab-link "bit-vectors.private" } " vocabulary because it does not perform type or bounds checks. User code should call " { $link >bit-vector } " instead." } ; + +HELP: ?V{ +{ $syntax "?V{ elements... }" } +{ $values { "elements" "a list of booleans" } } +{ $description "Marks the beginning of a literal bit vector. Literal bit vectors are terminated by " { $link POSTPONE: } } "." } +{ $examples { $code "?V{ t f t }" } } ; + diff --git a/core/bit-vectors/bit-vectors-tests.factor b/extra/bit-vectors/bit-vectors-tests.factor similarity index 100% rename from core/bit-vectors/bit-vectors-tests.factor rename to extra/bit-vectors/bit-vectors-tests.factor diff --git a/core/bit-vectors/bit-vectors.factor b/extra/bit-vectors/bit-vectors.factor similarity index 56% rename from core/bit-vectors/bit-vectors.factor rename to extra/bit-vectors/bit-vectors.factor index db941ac6f7..b011f146c5 100755 --- a/core/bit-vectors/bit-vectors.factor +++ b/extra/bit-vectors/bit-vectors.factor @@ -1,9 +1,20 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel kernel.private math sequences -sequences.private growable bit-arrays ; +sequences.private growable bit-arrays prettyprint.backend +parser ; IN: bit-vectors +TUPLE: bit-vector underlying fill ; + +M: bit-vector underlying underlying>> { bit-array } declare ; + +M: bit-vector set-underlying (>>underlying) ; + +M: bit-vector length fill>> { array-capacity } declare ; + +M: bit-vector set-fill (>>fill) ; + vector ( bit-array length -- bit-vector ) @@ -14,7 +25,8 @@ PRIVATE> : ( n -- bit-vector ) 0 bit-array>vector ; inline -: >bit-vector ( seq -- bit-vector ) ?V{ } clone-like ; +: >bit-vector ( seq -- bit-vector ) + T{ bit-vector f ?{ } 0 } clone-like ; M: bit-vector like drop dup bit-vector? [ @@ -31,3 +43,9 @@ M: bit-vector equal? M: bit-array new-resizable drop ; INSTANCE: bit-vector growable + +: ?V \ } [ >bit-vector ] parse-literal ; parsing + +M: bit-vector >pprint-sequence ; + +M: bit-vector pprint-delims drop \ ?V{ \ } ; diff --git a/core/bit-vectors/summary.txt b/extra/bit-vectors/summary.txt similarity index 100% rename from core/bit-vectors/summary.txt rename to extra/bit-vectors/summary.txt diff --git a/core/bit-vectors/tags.txt b/extra/bit-vectors/tags.txt similarity index 100% rename from core/bit-vectors/tags.txt rename to extra/bit-vectors/tags.txt diff --git a/core/byte-vectors/byte-vectors-docs.factor b/extra/byte-vectors/byte-vectors-docs.factor similarity index 79% rename from core/byte-vectors/byte-vectors-docs.factor rename to extra/byte-vectors/byte-vectors-docs.factor index 0f1054ee5e..f34bc20219 100755 --- a/core/byte-vectors/byte-vectors-docs.factor +++ b/extra/byte-vectors/byte-vectors-docs.factor @@ -3,7 +3,7 @@ byte-vectors.private combinators ; IN: byte-vectors ARTICLE: "byte-vectors" "Byte vectors" -"A byte vector is a resizable mutable sequence of unsigned bytes. The literal syntax is covered in " { $link "syntax-byte-vectors" } ". Byte vector words are found in the " { $vocab-link "byte-vectors" } " vocabulary." +"A byte vector is a resizable mutable sequence of unsigned bytes. Byte vector words are found in the " { $vocab-link "byte-vectors" } " vocabulary." $nl "Byte vectors form a class:" { $subsection byte-vector } @@ -11,6 +11,8 @@ $nl "Creating byte vectors:" { $subsection >byte-vector } { $subsection } +"Literal syntax:" +{ $subsection POSTPONE: BV{ } "If you don't care about initial capacity, a more elegant way to create a new byte vector is to write:" { $code "BV{ } clone" } ; @@ -32,3 +34,9 @@ HELP: byte-array>vector { $values { "byte-array" "an array" } { "length" "a non-negative integer" } { "byte-vector" byte-vector } } { $description "Creates a new byte vector using the array for underlying storage with the specified initial length." } { $warning "This word is in the " { $vocab-link "byte-vectors.private" } " vocabulary because it does not perform type or bounds checks. User code should call " { $link >byte-vector } " instead." } ; + +HELP: BV{ +{ $syntax "BV{ elements... }" } +{ $values { "elements" "a list of bytes" } } +{ $description "Marks the beginning of a literal byte vector. Literal byte vectors are terminated by " { $link POSTPONE: } } "." } +{ $examples { $code "BV{ 1 2 3 12 }" } } ; diff --git a/core/byte-vectors/byte-vectors-tests.factor b/extra/byte-vectors/byte-vectors-tests.factor similarity index 100% rename from core/byte-vectors/byte-vectors-tests.factor rename to extra/byte-vectors/byte-vectors-tests.factor diff --git a/core/byte-vectors/byte-vectors.factor b/extra/byte-vectors/byte-vectors.factor similarity index 55% rename from core/byte-vectors/byte-vectors.factor rename to extra/byte-vectors/byte-vectors.factor index 206a23f43b..a8351dc781 100755 --- a/core/byte-vectors/byte-vectors.factor +++ b/extra/byte-vectors/byte-vectors.factor @@ -1,9 +1,20 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel kernel.private math sequences -sequences.private growable byte-arrays ; +sequences.private growable byte-arrays prettyprint.backend +parser accessors ; IN: byte-vectors +TUPLE: byte-vector underlying fill ; + +M: byte-vector underlying underlying>> { byte-array } declare ; + +M: byte-vector set-underlying (>>underlying) ; + +M: byte-vector length fill>> { array-capacity } declare ; + +M: byte-vector set-fill (>>fill) ; + vector ( byte-array length -- byte-vector ) @@ -14,7 +25,8 @@ PRIVATE> : ( n -- byte-vector ) 0 byte-array>vector ; inline -: >byte-vector ( seq -- byte-vector ) BV{ } clone-like ; +: >byte-vector ( seq -- byte-vector ) + T{ byte-vector f B{ } 0 } clone-like ; M: byte-vector like drop dup byte-vector? [ @@ -31,3 +43,9 @@ M: byte-vector equal? M: byte-array new-resizable drop ; INSTANCE: byte-vector growable + +: BV{ \ } [ >byte-vector ] parse-literal ; parsing + +M: byte-vector >pprint-sequence ; + +M: byte-vector pprint-delims drop \ BV{ \ } ; diff --git a/core/byte-vectors/summary.txt b/extra/byte-vectors/summary.txt similarity index 100% rename from core/byte-vectors/summary.txt rename to extra/byte-vectors/summary.txt diff --git a/core/byte-vectors/tags.txt b/extra/byte-vectors/tags.txt similarity index 100% rename from core/byte-vectors/tags.txt rename to extra/byte-vectors/tags.txt diff --git a/extra/columns/authors.txt b/extra/columns/authors.txt new file mode 100644 index 0000000000..a44f8d7f8d --- /dev/null +++ b/extra/columns/authors.txt @@ -0,0 +1,2 @@ +Slava Pestov +Daniel Ehrenberg diff --git a/extra/columns/columns-docs.factor b/extra/columns/columns-docs.factor new file mode 100644 index 0000000000..6b2adce9d9 --- /dev/null +++ b/extra/columns/columns-docs.factor @@ -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 } ; + +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 } "." } ; + +HELP: ( 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 >array ." + "{ 1 4 7 }" + } +} +{ $notes + "In the same sense that " { $link } " is a virtual variant of " { $link reverse } ", " { $link } " is a virtual variant of " { $snippet "swap [ nth ] curry map" } "." +} ; + +ABOUT: "columns" diff --git a/extra/columns/columns-tests.factor b/extra/columns/columns-tests.factor new file mode 100644 index 0000000000..657b9e0a25 --- /dev/null +++ b/extra/columns/columns-tests.factor @@ -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 >array ] unit-test +[ ] [ "seq" get 1 [ sq ] change-each ] unit-test +[ { 4 25 64 } ] [ "seq" get 1 >array ] unit-test diff --git a/extra/columns/columns.factor b/extra/columns/columns.factor new file mode 100644 index 0000000000..7e4a7fd408 --- /dev/null +++ b/extra/columns/columns.factor @@ -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 + +M: column virtual-seq seq>> ; +M: column virtual@ dup col>> -rot seq>> nth bounds-check ; +M: column length seq>> length ; + +INSTANCE: column virtual-sequence diff --git a/extra/columns/summary.txt b/extra/columns/summary.txt new file mode 100644 index 0000000000..c4ade7fb51 --- /dev/null +++ b/extra/columns/summary.txt @@ -0,0 +1 @@ +Virtual sequence view of a matrix column diff --git a/core/float-vectors/tags.txt b/extra/columns/tags.txt similarity index 100% rename from core/float-vectors/tags.txt rename to extra/columns/tags.txt diff --git a/core/float-vectors/float-vectors-docs.factor b/extra/float-vectors/float-vectors-docs.factor similarity index 83% rename from core/float-vectors/float-vectors-docs.factor rename to extra/float-vectors/float-vectors-docs.factor index ef0645a0af..8d25da54be 100755 --- a/core/float-vectors/float-vectors-docs.factor +++ b/extra/float-vectors/float-vectors-docs.factor @@ -11,6 +11,8 @@ $nl "Creating float vectors:" { $subsection >float-vector } { $subsection } +"Literal syntax:" +{ $subsection POSTPONE: FV{ } "If you don't care about initial capacity, a more elegant way to create a new float vector is to write:" { $code "FV{ } clone" } ; @@ -32,3 +34,9 @@ HELP: float-array>vector { $values { "float-array" "an array" } { "length" "a non-negative integer" } { "float-vector" float-vector } } { $description "Creates a new float vector using the array for underlying storage with the specified initial length." } { $warning "This word is in the " { $vocab-link "float-vectors.private" } " vocabulary because it does not perform type or bounds checks. User code should call " { $link >float-vector } " instead." } ; + +HELP: FV{ +{ $syntax "FV{ elements... }" } +{ $values { "elements" "a list of real numbers" } } +{ $description "Marks the beginning of a literal float vector. Literal float vectors are terminated by " { $link POSTPONE: } } "." } +{ $examples { $code "FV{ 1.0 2.0 3.0 }" } } ; diff --git a/core/float-vectors/float-vectors-tests.factor b/extra/float-vectors/float-vectors-tests.factor similarity index 100% rename from core/float-vectors/float-vectors-tests.factor rename to extra/float-vectors/float-vectors-tests.factor diff --git a/core/float-vectors/float-vectors.factor b/extra/float-vectors/float-vectors.factor similarity index 56% rename from core/float-vectors/float-vectors.factor rename to extra/float-vectors/float-vectors.factor index 7f62f6f95c..f0db37610a 100755 --- a/core/float-vectors/float-vectors.factor +++ b/extra/float-vectors/float-vectors.factor @@ -1,9 +1,20 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel kernel.private math sequences -sequences.private growable float-arrays ; +sequences.private growable float-arrays prettyprint.backend +parser ; IN: float-vectors +TUPLE: float-vector underlying fill ; + +M: float-vector underlying underlying>> { float-array } declare ; + +M: float-vector set-underlying (>>underlying) ; + +M: float-vector length fill>> { array-capacity } declare ; + +M: float-vector set-fill (>>fill) ; + vector ( float-array length -- float-vector ) @@ -14,7 +25,8 @@ PRIVATE> : ( n -- float-vector ) 0.0 0 float-array>vector ; inline -: >float-vector ( seq -- float-vector ) FV{ } clone-like ; +: >float-vector ( seq -- float-vector ) + T{ float-vector f F{ } 0 } clone-like ; M: float-vector like drop dup float-vector? [ @@ -31,3 +43,9 @@ M: float-vector equal? M: float-array new-resizable drop ; INSTANCE: float-vector growable + +: FV{ \ } [ >float-vector ] parse-literal ; parsing + +M: float-vector >pprint-sequence ; + +M: float-vector pprint-delims drop \ FV{ \ } ; diff --git a/core/float-vectors/summary.txt b/extra/float-vectors/summary.txt similarity index 100% rename from core/float-vectors/summary.txt rename to extra/float-vectors/summary.txt diff --git a/extra/float-vectors/tags.txt b/extra/float-vectors/tags.txt new file mode 100644 index 0000000000..42d711b32b --- /dev/null +++ b/extra/float-vectors/tags.txt @@ -0,0 +1 @@ +collections diff --git a/extra/help/handbook/handbook.factor b/extra/help/handbook/handbook.factor index 4e6bfe4888..d5bc1875e4 100755 --- a/extra/help/handbook/handbook.factor +++ b/extra/help/handbook/handbook.factor @@ -145,9 +145,9 @@ ARTICLE: "collections" "Collections" { $subsection "vectors" } "Resizable specialized sequences:" { $subsection "sbufs" } -{ $subsection "bit-vectors" } -{ $subsection "byte-vectors" } -{ $subsection "float-vectors" } +{ $vocab-subsection "Bit vectors" "bit-vectors" } +{ $vocab-subsection "Byte vectors" "byte-vectors" } +{ $vocab-subsection "Float vectors" "float-vectors" } { $heading "Associative mappings" } { $subsection "assocs" } { $subsection "namespaces" } diff --git a/extra/help/help.factor b/extra/help/help.factor index aa2704a799..e0b2709932 100755 --- a/extra/help/help.factor +++ b/extra/help/help.factor @@ -38,7 +38,7 @@ M: predicate word-help* drop \ $predicate ; \ $error-description swap word-help elements empty? not ; : sort-articles ( seq -- newseq ) - [ dup article-title ] { } map>assoc sort-values 0 ; + [ dup article-title ] { } map>assoc sort-values keys ; : all-errors ( -- seq ) all-words [ error? ] subset sort-articles ; diff --git a/extra/math/fft/fft.factor b/extra/math/fft/fft.factor index 625be534ce..4d4068158e 100644 --- a/extra/math/fft/fft.factor +++ b/extra/math/fft/fft.factor @@ -1,7 +1,7 @@ ! Fast Fourier Transform, copyright (C) 2007 Hans Schmid ! http://dressguardmeister.blogspot.com/2007/01/fft.html USING: arrays sequences math math.vectors math.constants -math.functions kernel splitting ; +math.functions kernel splitting columns ; IN: math.fft : n^v ( n v -- w ) [ ^ ] with map ; diff --git a/extra/math/haar/haar.factor b/extra/math/haar/haar.factor index 91d9fd8ece..9254fd0ce7 100644 --- a/extra/math/haar/haar.factor +++ b/extra/math/haar/haar.factor @@ -1,5 +1,5 @@ ! Haar wavelet transform -- http://dmr.ath.cx/gfx/haar/ -USING: sequences math kernel splitting ; +USING: sequences math kernel splitting columns ; IN: math.haar : averages ( seq -- seq ) diff --git a/extra/sudoku/sudoku.factor b/extra/sudoku/sudoku.factor index b0ba85c97f..1cb82253b1 100644 --- a/extra/sudoku/sudoku.factor +++ b/extra/sudoku/sudoku.factor @@ -1,6 +1,6 @@ ! Based on http://www.ffconsultancy.com/ocaml/sudoku/index.html USING: sequences namespaces kernel math math.parser io -io.styles combinators ; +io.styles combinators columns ; IN: sudoku SYMBOL: solutions diff --git a/extra/tools/deploy/deploy.factor b/extra/tools/deploy/deploy.factor index bbeadc40cd..e57cc1f04b 100755 --- a/extra/tools/deploy/deploy.factor +++ b/extra/tools/deploy/deploy.factor @@ -1,10 +1,13 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: tools.deploy.backend system vocabs.loader kernel ; +USING: tools.deploy.backend system vocabs.loader kernel +combinators ; IN: tools.deploy : deploy ( vocab -- ) deploy* ; -os macosx? [ "tools.deploy.macosx" require ] when -os winnt? [ "tools.deploy.windows" require ] when -os unix? [ "tools.deploy.unix" require ] when \ No newline at end of file +{ + { [ os macosx? ] [ "tools.deploy.macosx" ] } + { [ os winnt? ] [ "tools.deploy.windows" ] } + { [ os unix? ] [ "tools.deploy.unix" ] } +} cond require \ No newline at end of file diff --git a/extra/tools/deploy/macosx/macosx.factor b/extra/tools/deploy/macosx/macosx.factor index ca710e9d28..d38b40db4b 100755 --- a/extra/tools/deploy/macosx/macosx.factor +++ b/extra/tools/deploy/macosx/macosx.factor @@ -31,10 +31,14 @@ IN: tools.deploy.macosx write-plist ; : create-app-dir ( vocab bundle-name -- vm ) - dup "Frameworks" copy-bundle-dir - dup "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir - dup "Contents/Resources/" copy-fonts - 2dup create-app-plist "Contents/MacOS/" append-path "" copy-vm ; + [ + nip + [ "Frameworks" copy-bundle-dir ] + [ "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir ] + [ "Contents/Resources/" copy-fonts ] tri + ] + [ create-app-plist ] + [ "Contents/MacOS/" append-path "" copy-vm ] 2tri ; : deploy.app-image ( vocab bundle-name -- str ) [ % "/Contents/Resources/" % % ".image" % ] "" make ; @@ -43,9 +47,8 @@ IN: tools.deploy.macosx deploy-name get ".app" append ; : show-in-finder ( path -- ) - NSWorkspace - -> sharedWorkspace - over rot parent-directory + [ NSWorkspace -> sharedWorkspace ] + [ normalize-path [ ] [ parent-directory ] bi ] bi* -> selectFile:inFileViewerRootedAtPath: drop ; M: macosx deploy* ( vocab -- ) @@ -56,6 +59,6 @@ M: macosx deploy* ( vocab -- ) [ bundle-name create-app-dir ] keep [ bundle-name deploy.app-image ] keep namespace make-deploy-image - bundle-name normalize-path show-in-finder + bundle-name show-in-finder ] bind ] with-directory ; diff --git a/extra/tools/deploy/unix/unix.factor b/extra/tools/deploy/unix/unix.factor index a995d66cd8..6f5a0304a2 100644 --- a/extra/tools/deploy/unix/unix.factor +++ b/extra/tools/deploy/unix/unix.factor @@ -3,21 +3,21 @@ USING: io io.files io.backend kernel namespaces sequences system tools.deploy.backend tools.deploy.config assocs hashtables prettyprint ; -IN: tools.deploy.linux - -: create-app-dir ( vocab bundle-name -- vm ) - dup "" copy-fonts - "" copy-vm ; - -: bundle-name ( -- str ) - deploy-name get ; +IN: tools.deploy.unix -M: linux deploy* ( vocab -- ) - "." resource-path [ - dup deploy-config [ - [ bundle-name create-app-dir ] keep - [ bundle-name image-name ] keep - namespace make-deploy-image - bundle-name normalize-path [ "Binary deployed to " % % "." % ] "" make print - ] bind - ] with-directory ; \ No newline at end of file +: create-app-dir ( vocab bundle-name -- vm ) + dup "" copy-fonts + "" copy-vm ; + +: bundle-name ( -- str ) + deploy-name get ; + +M: unix deploy* ( vocab -- ) + "." resource-path [ + dup deploy-config [ + [ bundle-name create-app-dir ] keep + [ bundle-name image-name ] keep + namespace make-deploy-image + bundle-name normalize-path [ "Binary deployed to " % % "." % ] "" make print + ] bind + ] with-directory ; \ No newline at end of file diff --git a/extra/tools/deploy/windows/windows.factor b/extra/tools/deploy/windows/windows.factor index 4f6527a4ce..5af3062e39 100755 --- a/extra/tools/deploy/windows/windows.factor +++ b/extra/tools/deploy/windows/windows.factor @@ -6,8 +6,7 @@ prettyprint windows.shell32 windows.user32 ; IN: tools.deploy.windows : copy-dlls ( bundle-name -- ) - { "freetype6.dll" "zlib1.dll" "factor.dll" } - [ resource-path ] map + { "resource:freetype6.dll" "resource:zlib1.dll" "resource:factor.dll" } swap copy-files-into ; : create-exe-dir ( vocab bundle-name -- vm ) @@ -21,6 +20,6 @@ M: winnt deploy* [ deploy-name get create-exe-dir ] keep [ deploy-name get image-name ] keep [ namespace make-deploy-image ] keep - (normalize-path) open-in-explorer + open-in-explorer ] bind ] with-directory ; diff --git a/extra/ui/gadgets/grids/grids.factor b/extra/ui/gadgets/grids/grids.factor index 342c360c83..9951256249 100644 --- a/extra/ui/gadgets/grids/grids.factor +++ b/extra/ui/gadgets/grids/grids.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2006 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel math namespaces sequences words io -io.streams.string math.vectors ui.gadgets ; +io.streams.string math.vectors ui.gadgets columns ; IN: ui.gadgets.grids TUPLE: grid children gap fill? ; diff --git a/extra/ui/gestures/gestures.factor b/extra/ui/gestures/gestures.factor index f68a70c2bd..ed0f38b743 100755 --- a/extra/ui/gestures/gestures.factor +++ b/extra/ui/gestures/gestures.factor @@ -3,7 +3,7 @@ USING: arrays assocs kernel math models namespaces sequences words strings system hashtables math.parser math.vectors classes.tuple classes ui.gadgets boxes -calendar alarms symbols combinators sets ; +calendar alarms symbols combinators sets columns ; IN: ui.gestures : set-gestures ( class hash -- ) "gestures" set-word-prop ; diff --git a/extra/windows/shell32/shell32.factor b/extra/windows/shell32/shell32.factor index d64fb68cb3..f938ca15e6 100644 --- a/extra/windows/shell32/shell32.factor +++ b/extra/windows/shell32/shell32.factor @@ -1,6 +1,6 @@ USING: alien alien.c-types alien.syntax combinators kernel windows windows.user32 windows.ole32 -windows.com windows.com.syntax ; +windows.com windows.com.syntax io.files ; IN: windows.shell32 : CSIDL_DESKTOP HEX: 00 ; inline @@ -83,7 +83,7 @@ FUNCTION: HINSTANCE ShellExecuteW ( HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFi : ShellExecute ShellExecuteW ; inline : open-in-explorer ( dir -- ) - f "open" rot f f SW_SHOWNORMAL ShellExecute drop ; + f "open" rot (normalize-path) f f SW_SHOWNORMAL ShellExecute drop ; : shell32-error ( n -- ) ole32-error ; inline