]> gitweb.factorcode.org Git - factor.git/commitdiff
basis/extra: move fewer things.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 2 Apr 2020 04:36:41 +0000 (21:36 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 2 Apr 2020 04:37:28 +0000 (21:37 -0700)
48 files changed:
basis/bootstrap/image/upload/upload.factor
basis/couchdb/authors.txt [new file with mode: 0644]
basis/couchdb/couchdb-tests.factor [new file with mode: 0644]
basis/couchdb/couchdb.factor [new file with mode: 0644]
basis/couchdb/tags.txt [new file with mode: 0644]
basis/editors/visual-studio-code/visual-studio-code.factor
basis/english/english.factor
basis/escape-strings/escape-strings.factor
basis/furnace/furnace.factor
basis/io/encodings/utf7/utf7.factor
basis/math/floating-point/authors.txt [new file with mode: 0644]
basis/math/floating-point/floating-point-tests.factor [new file with mode: 0644]
basis/math/floating-point/floating-point.factor [new file with mode: 0644]
basis/math/floating-point/tags.txt [new file with mode: 0644]
basis/math/matrices/matrices.factor
basis/math/trig/tags.txt [new file with mode: 0644]
basis/math/trig/trig.factor [new file with mode: 0644]
basis/method-chains/authors.txt [new file with mode: 0644]
basis/method-chains/method-chains-docs.factor [new file with mode: 0644]
basis/method-chains/method-chains-tests.factor [new file with mode: 0644]
basis/method-chains/method-chains.factor [new file with mode: 0644]
basis/method-chains/summary.txt [new file with mode: 0644]
basis/sequences/deep/deep-tests.factor
basis/sequences/deep/deep.factor
basis/tools/which/authors.txt [new file with mode: 0644]
basis/tools/which/which-docs.factor [new file with mode: 0644]
basis/tools/which/which.factor [new file with mode: 0644]
extra/cli/git/git.factor
extra/couchdb/authors.txt [deleted file]
extra/couchdb/couchdb-tests.factor [deleted file]
extra/couchdb/couchdb.factor [deleted file]
extra/couchdb/tags.txt [deleted file]
extra/math/floating-point/authors.txt [deleted file]
extra/math/floating-point/floating-point-tests.factor [deleted file]
extra/math/floating-point/floating-point.factor [deleted file]
extra/math/floating-point/tags.txt [deleted file]
extra/math/trig/tags.txt [deleted file]
extra/math/trig/trig.factor [deleted file]
extra/method-chains/authors.txt [deleted file]
extra/method-chains/method-chains-docs.factor [deleted file]
extra/method-chains/method-chains-tests.factor [deleted file]
extra/method-chains/method-chains.factor [deleted file]
extra/method-chains/summary.txt [deleted file]
extra/sequences/extras/extras-tests.factor
extra/sequences/extras/extras.factor
extra/tools/which/authors.txt [deleted file]
extra/tools/which/which-docs.factor [deleted file]
extra/tools/which/which.factor [deleted file]

index 08f3d023613f90da55ff66f6e85bc7c00b8b7ede..47a0fbfc12c879614a551d24d5b171e403125269 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! Copyright (C) 2015 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: bootstrap.image checksums checksums.openssl cli.git fry
-io io.directories io.encodings.ascii io.encodings.utf8 io.files
+USING: bootstrap.image checksums checksums.openssl fry io
+io.directories io.encodings.ascii io.encodings.utf8 io.files
 io.files.temp io.files.unique io.launcher io.pathnames kernel
-make math.parser namespaces sequences splitting system ;
+make math.parser namespaces sequences splitting system unicode ;
 IN: bootstrap.image.upload
 
 SYMBOL: upload-images-destination
@@ -21,7 +21,11 @@ SYMBOL: build-images-destination
     or ;
 
 : factor-git-branch ( -- name )
-    image-path parent-directory git-current-branch ;
+    image-path parent-directory [
+        { "git" "rev-parse" "--abbrev-ref" "HEAD" }
+        utf8 <process-reader> stream-contents
+        [ blank? ] trim-tail
+    ] with-directory ;
 
 : git-branch-destination ( -- dest )
     build-images-destination get
diff --git a/basis/couchdb/authors.txt b/basis/couchdb/authors.txt
new file mode 100644 (file)
index 0000000..e9c193b
--- /dev/null
@@ -0,0 +1 @@
+Alex Chapman
diff --git a/basis/couchdb/couchdb-tests.factor b/basis/couchdb/couchdb-tests.factor
new file mode 100644 (file)
index 0000000..3cb84d5
--- /dev/null
@@ -0,0 +1,54 @@
+! Copyright (C) 2008 Alex Chapman
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs couchdb hashtables kernel namespaces
+random.data sequences strings tools.test ;
+IN: couchdb.tests
+
+! You must have a CouchDB server (currently only the version from svn will
+! work) running on localhost and listening on the default port for these tests
+! to work.
+
+<default-server> "factor-test" <db> [
+    [ ] [ couch get ensure-db ] unit-test
+    [ couch get create-db ] must-fail
+    [ ] [ couch get delete-db ] unit-test
+    [ couch get delete-db ] must-fail
+    [ ] [ couch get ensure-db ] unit-test
+    [ ] [ couch get ensure-db ] unit-test
+    [ 0 ] [ couch get db-info "doc_count" of ] unit-test
+    [ ] [ couch get compact-db ] unit-test
+    [ t ] [ couch get server>> next-uuid string? ] unit-test
+    [ ] [ H{
+            { "Subject" "I like Planktion" }
+            { "Tags" { "plankton" "baseball" "decisions" } }
+            { "Body"
+              "I decided today that I don't like baseball. I like plankton." }
+            { "Author" "Rusty" }
+            { "PostedDate" "2006-08-15T17:30:12Z-04:00" }
+           } save-doc ] unit-test
+    [ t ] [ couch get all-docs "rows" of first "id" of dup "id" set string? ] unit-test
+    [ t ] [ "id" get dup load-doc id> = ] unit-test
+    [ ] [ "id" get load-doc save-doc ] unit-test
+    [ "Rusty" ] [ "id" get load-doc "Author" of ] unit-test
+    [ ] [ "id" get load-doc "Alex" "Author" pick set-at save-doc ] unit-test
+    [ "Alex" ] [ "id" get load-doc "Author" of ] unit-test
+    [ 1 ] [ "function(doc) { emit(null, doc) }" temp-view-map "total_rows" of ] unit-test
+    [ ] [ H{
+         { "_id" "_design/posts" }
+         { "language" "javascript" }
+         { "views" H{
+             { "all" H{ { "map" "function(doc) { emit(null, doc) }" } } }
+           }
+         }
+       } save-doc ] unit-test
+    [ t ] [ "id" get load-doc delete-doc string? ] unit-test
+    [ "id" get load-doc ] must-fail
+
+    { t } [
+        "oga" "boga" associate
+        couch get db-url 10 random-string append
+        couch-put "ok" of
+    ] unit-test
+
+    [ ] [ couch get delete-db ] unit-test
+] with-couch
diff --git a/basis/couchdb/couchdb.factor b/basis/couchdb/couchdb.factor
new file mode 100644 (file)
index 0000000..15db192
--- /dev/null
@@ -0,0 +1,199 @@
+! Copyright (C) 2008, 2009 Alex Chapman
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs continuations debugger fry hashtables http
+http.client io io.encodings.string io.encodings.utf8 json.reader
+json.writer kernel locals make math math.parser namespaces sequences
+strings urls.encoding vectors ;
+IN: couchdb
+
+! NOTE: This code only works with the latest couchdb (0.9.*), because old
+! versions didn't provide the /_uuids feature which this code relies on when
+! creating new documents.
+
+SYMBOL: couch
+: with-couch ( db quot -- )
+    couch swap with-variable ; inline
+
+! errors
+TUPLE: couchdb-error { data assoc } ;
+C: <couchdb-error> couchdb-error
+
+M: couchdb-error error. ( error -- )
+    "CouchDB Error: " write data>>
+    "error" over at [ print ] when*
+    "reason" of [ print ] when* ;
+
+PREDICATE: file-exists-error < couchdb-error
+    data>> "error" of "file_exists" = ;
+
+! http tools
+: couch-http-request ( request -- data )
+    [ http-request ] [
+        dup download-failed? [
+            response>> body>> json> <couchdb-error> throw
+        ] [
+            rethrow
+        ] if
+    ] recover nip ;
+
+: couch-request ( request -- assoc )
+    couch-http-request json> ;
+
+: couch-get ( url -- assoc )
+    <get-request> couch-request ;
+
+: <json-post-data> ( assoc -- post-data )
+    >json utf8 encode "application/json" <post-data> swap >>data ;
+
+: couch-put ( assoc url -- assoc' )
+    [ <json-post-data> ] dip <put-request> couch-request ;
+
+: couch-post ( assoc url -- assoc' )
+    [ <json-post-data> ] dip <post-request> couch-request ;
+
+: couch-delete ( url -- assoc )
+    <delete-request> couch-request ;
+
+: response-ok ( assoc -- assoc )
+    "ok" over delete-at* and t assert= ;
+
+: response-ok* ( assoc -- )
+    response-ok drop ;
+
+! server
+TUPLE: server { host string } { port integer } { uuids vector } { uuids-to-cache integer } ;
+
+CONSTANT: default-couch-host "localhost"
+CONSTANT: default-couch-port 5984
+CONSTANT: default-uuids-to-cache 100
+
+: <server> ( host port -- server )
+    V{ } clone default-uuids-to-cache server boa ;
+
+: <default-server> ( -- server )
+    default-couch-host default-couch-port <server> ;
+
+: (server-url) ( server -- )
+    "http://" % [ host>> % ] [ CHAR: : , port>> number>string % ] bi CHAR: / , ; inline
+
+: server-url ( server -- url )
+    [ (server-url) ] "" make ;
+
+: all-dbs ( server -- dbs )
+    server-url "_all_dbs" append couch-get ;
+
+: uuids-url ( server -- url )
+    [ dup server-url % "_uuids?count=" % uuids-to-cache>> number>string % ] "" make ;
+
+: uuids-get ( server -- uuids )
+     uuids-url couch-get "uuids" of >vector ;
+
+: get-uuids ( server -- server )
+    dup uuids-get [ nip ] curry change-uuids ;
+
+: ensure-uuids ( server -- server )
+    dup uuids>> empty? [ get-uuids ] when ;
+
+: next-uuid ( server -- uuid )
+    ensure-uuids uuids>> pop ;
+
+! db
+TUPLE: db { server server } { name string } ;
+C: <db> db
+
+: (db-url) ( db -- )
+    [ server>> server-url % ] [ name>> % ] bi CHAR: / , ; inline
+
+: db-url ( db -- url )
+    [ (db-url) ] "" make ;
+
+: create-db ( db -- )
+    f swap db-url couch-put response-ok* ;
+
+: ensure-db ( db -- )
+    '[ _ create-db ] [ file-exists-error? ] ignore-error ;
+
+: delete-db ( db -- )
+    db-url couch-delete drop ;
+
+: db-info ( db -- info )
+    db-url couch-get ;
+
+: all-docs ( db -- docs )
+    ! TODO: queries. Maybe pass in a hashtable with options
+    db-url "_all_docs" append couch-get ;
+
+: compact-db ( db -- )
+    f swap db-url "_compact" append couch-post response-ok* ;
+
+! documents
+: id> ( assoc -- id ) "_id" of ;
+: >id ( assoc id -- assoc ) "_id" pick set-at ;
+: rev> ( assoc -- rev ) "_rev" of ;
+: >rev ( assoc rev -- assoc ) "_rev" pick set-at ;
+: attachments> ( assoc -- attachments ) "_attachments" of ;
+: >attachments ( assoc attachments -- assoc ) "_attachments" pick set-at ;
+
+:: copy-key ( to from to-key from-key -- )
+    from-key from at
+    to-key to set-at ;
+
+: copy-id ( to from -- )
+    "_id" "id" copy-key ;
+
+: copy-rev ( to from -- )
+    "_rev" "rev" copy-key ;
+
+: id-url ( id -- url )
+    couch get db-url swap url-encode-full append ;
+
+: doc-url ( assoc -- url )
+    id> id-url ;
+
+: temp-view ( view -- results )
+    couch get db-url "_temp_view" append couch-post ;
+
+: temp-view-map ( map -- results )
+    "map" associate temp-view ;
+
+: save-doc-as ( assoc id -- )
+    dupd id-url couch-put response-ok
+    [ copy-id ] [ copy-rev ] 2bi ;
+
+: save-new-doc ( assoc -- )
+    couch get server>> next-uuid save-doc-as ;
+
+: save-doc ( assoc -- )
+    dup id> [ save-doc-as ] [ save-new-doc ] if* ;
+
+: load-doc ( id -- assoc )
+    id-url couch-get ;
+
+: delete-doc ( assoc -- deletion-revision )
+    [
+        [ doc-url % ]
+        [ "?rev=" % "_rev" of % ] bi
+    ] "" make couch-delete response-ok "rev" of ;
+
+: remove-keys ( assoc keys -- )
+    swap [ delete-at ] curry each ;
+
+: remove-couch-info ( assoc -- )
+    { "_id" "_rev" "_attachments" } remove-keys ;
+
+! : construct-attachment ( content-type data -- assoc )
+!     H{ } clone "name" pick set-at "content-type" pick set-at ;
+!
+! : add-attachment ( assoc name attachment -- )
+!     pick attachments> [ H{ } clone ] unless*
+!
+! : attach ( assoc name content-type data -- )
+!     construct-attachment H{ } clone
+
+! TODO:
+! - startkey, limit, descending, etc.
+! - loading specific revisions
+! - views
+! - attachments
+! - bulk insert/update
+! - ...?
diff --git a/basis/couchdb/tags.txt b/basis/couchdb/tags.txt
new file mode 100644 (file)
index 0000000..fc7cc1c
--- /dev/null
@@ -0,0 +1,2 @@
+not tested
+database
index f996cbec8a495ec5e1b74271ad6c63d4c8d89457..5ac6c00bfd3e58cd0c864d3f2591cf27d2d09c66 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2015 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators.extras combinators.short-circuit editors
+USING: combinators.short-circuit editors
 generalizations io.files io.pathnames io.standard-paths kernel
 make math.parser memoize namespaces sequences system tools.which ;
 IN: editors.visual-studio-code
@@ -35,7 +35,7 @@ M: linux find-visual-studio-code-invocation
         [ "Code" which ]
         [ home "VSCode-linux-x64/Code" append-path ]
         [ "/usr/share/code/code" ]
-    } [ [ exists? ] ?1arg ] map-compose 0|| ;
+    } [ dup exists? [ drop f ] unless ] map-compose 0|| ;
 
 M: windows find-visual-studio-code-invocation
     {
index 48cf24bdf6eed422867692e8459d7ce89d4dbe44..3ea32284d6dbb0bea70383b0ef78dc137dfe3c72 100644 (file)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2015, 2018 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
-USING: accessors arrays assocs assocs.extras combinators
-help.markup kernel literals locals math math.parser sequences
-sequences.extras splitting unicode words ;
-
+USING: accessors arrays assocs combinators help.markup kernel
+literals locals math math.order math.parser sequences splitting
+unicode words ;
 IN: english
 
 <PRIVATE
@@ -95,7 +94,7 @@ CONSTANT: singular-to-plural H{
 }
 >>
 
-CONSTANT: plural-to-singular $[ singular-to-plural assoc-invert ]
+CONSTANT: plural-to-singular $[ singular-to-plural [ swap ] assoc-map ]
 
 :: match-case ( master disciple -- master' )
     {
@@ -168,8 +167,11 @@ PRIVATE>
 : ?plural-article ( word -- article )
     dup singular? [ a/an ] [ drop "the" ] if ;
 
-: comma-list ( parts conjunction  -- clause-seq )
-    [ ", " interleaved ] dip over length dup 3 >= [
+: comma-list ( parts conjunction -- clause-seq )
+    [
+        [ length dup 1 [-] + ", " <array> ]
+        [ [ 2 * pick set-nth ] each-index ] bi
+    ] dip over length dup 3 >= [
         [ 3 > ", " " " ? " " surround ] [ 2 - pick set-nth ] bi
     ] [ 2drop ] if ;
 
index 09fe48836c68ebd8b5a1ff2926ad68b0508e0a4e..5fa76185546f641a6a05a54e40927f66bc5f24ca 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2017 John Benediktsson, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: assocs assocs.extras combinators kernel math math.order
-math.statistics sequences sequences.extras sets ;
+USING: assocs combinators kernel math math.order
+math.statistics sequences sets ;
 IN: escape-strings
 
 : find-escapes ( str -- set )
@@ -32,7 +32,7 @@ IN: escape-strings
     [ escape-string ] dip prepend ;
 
 : escape-simplest ( str -- str' )
-    dup { CHAR: ' CHAR: " CHAR: \r CHAR: \n CHAR: \s } counts {
+    dup histogram {
         ! { [ dup { CHAR: ' CHAR: \r CHAR: \n CHAR: \s } values-of sum 0 = ] [ drop "'" prepend ] }
         { [ dup CHAR: " of not ] [ drop "\"" "\"" surround ] }
         [ drop escape-string ]
index 2d12676b3a10683406ac99c4f7d269cee078ea6b..8665fe5f2a1ab766d97c39cc52a79f64a1e10ded 100644 (file)
@@ -25,4 +25,4 @@ USE: vocabs
 "furnace.scopes" require
 "furnace.sessions" require
 "furnace.syndication" require
-"webapps.user-admin" require
+"webapps.user-admin" require
index 40d4fe5490834ca7fe3e726d15652db153c0b427..76c89d98851d965bde130b21128d2c56ea6d6fb6 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2013-2014 Björn Lindqvist
 ! See http://factorcode.org/license.txt for BSD license
-USING: accessors ascii base64 fry grouping.extras io
-io.encodings io.encodings.string io.encodings.utf16 kernel math
+USING: accessors ascii assocs base64 fry io io.encodings
+io.encodings.string io.encodings.utf16 kernel math
 math.functions sequences splitting strings ;
 IN: io.encodings.utf7
 
@@ -28,13 +28,13 @@ TUPLE: utf7codec dialect buffer ;
 : raw-base64> ( str -- str' )
     dup length 4 / ceiling 4 * CHAR: = pad-tail base64> utf16be decode ;
 
-: encode-chunk ( repl-pair surround-pair chunk ascii? -- bytes )
+: encode-chunk ( repl-pair surround-pair chunk printable? -- bytes )
     [ swap [ first ] [ concat ] bi replace nip ]
     [ >raw-base64 -rot [ first2 replace ] [ first2 surround ] bi* ] if ;
 
 : encode-utf7-string ( str codec -- bytes )
-    [ [ printable? ] group-by ] dip
-    dialect>> first2 '[ _ _ rot first2 swap encode-chunk ] map
+    [ [ printable? ] collect-by ] dip dialect>> first2
+    '[ [ _ _ ] 2dip swap encode-chunk ] { } assoc>map
     B{ } concat-as ;
 
 M: utf7codec encode-string ( str stream codec -- )
diff --git a/basis/math/floating-point/authors.txt b/basis/math/floating-point/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/math/floating-point/floating-point-tests.factor b/basis/math/floating-point/floating-point-tests.factor
new file mode 100644 (file)
index 0000000..b1f0864
--- /dev/null
@@ -0,0 +1,30 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: tools.test math.floating-point kernel
+math.constants fry sequences math random ;
+IN: math.floating-point.tests
+
+{ t } [ pi >double< >double pi = ] unit-test
+{ t } [ -1.0 >double< >double -1.0 = ] unit-test
+
+{ t } [ 1/0. infinity? ] unit-test
+{ t } [ -1/0. infinity? ] unit-test
+{ f } [ 0/0. infinity? ] unit-test
+{ f } [ 10. infinity? ] unit-test
+{ f } [ -10. infinity? ] unit-test
+{ f } [ 0. infinity? ] unit-test
+
+{ 0 } [ 0.0 double>ratio ] unit-test
+{ 1 } [ 1.0 double>ratio ] unit-test
+{ 1/2 } [ 0.5 double>ratio ] unit-test
+{ 3/4 } [ 0.75 double>ratio ] unit-test
+{ 12+1/2 } [ 12.5 double>ratio ] unit-test
+{ -12-1/2 } [ -12.5 double>ratio ] unit-test
+{ 3+39854788871587/281474976710656 } [ pi double>ratio ] unit-test
+
+: roundtrip ( n -- )
+    [ '[ _ ] ] keep '[ _ double>ratio >float ] unit-test ;
+
+{ 1 12 123 1234 } [ bits>double roundtrip ] each
+
+100 [ -10.0 10.0 uniform-random-float roundtrip ] times
diff --git a/basis/math/floating-point/floating-point.factor b/basis/math/floating-point/floating-point.factor
new file mode 100644 (file)
index 0000000..a3e6f2d
--- /dev/null
@@ -0,0 +1,56 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel math sequences prettyprint math.parser io
+math.functions math.bitwise combinators.short-circuit ;
+IN: math.floating-point
+
+: (double-sign) ( bits -- n ) -63 shift ; inline
+: double-sign ( double -- n ) double>bits (double-sign) ;
+
+: (double-exponent-bits) ( bits -- n )
+    -52 shift 11 on-bits mask ; inline
+
+: double-exponent-bits ( double -- n )
+    double>bits (double-exponent-bits) ;
+
+: (double-mantissa-bits) ( double -- n )
+    52 on-bits mask ;
+
+: double-mantissa-bits ( double -- n )
+    double>bits (double-mantissa-bits) ;
+
+: >double ( S E M -- frac )
+    [ 52 shift ] dip
+    [ 63 shift ] 2dip bitor bitor bits>double ;
+
+: >double< ( double -- S E M )
+    double>bits
+    [ (double-sign) ]
+    [ (double-exponent-bits) ]
+    [ (double-mantissa-bits) ] tri ;
+
+: double. ( double -- )
+    double>bits
+    [ (double-sign) .b ]
+    [ (double-exponent-bits) >bin 11 CHAR: 0 pad-head bl print ]
+    [
+        (double-mantissa-bits) >bin 52 CHAR: 0 pad-head
+        11 [ bl ] times print
+    ] tri ;
+
+: infinity? ( double -- ? )
+    double>bits
+    {
+        [ (double-exponent-bits) 11 on-bits = ]
+        [ (double-mantissa-bits) 0 = ]
+    } 1&& ;
+
+: check-special ( n -- n )
+    dup fp-special? [ "cannot be special" throw ] when ;
+
+: double>ratio ( double -- a/b )
+    check-special double>bits
+    [ (double-sign) zero? 1 -1 ? ]
+    [ (double-mantissa-bits) 52 2^ / ]
+    [ (double-exponent-bits) ] tri
+    [ 1 ] [ [ 1 + ] dip ] if-zero 1023 - 2 swap ^ * * ;
diff --git a/basis/math/floating-point/tags.txt b/basis/math/floating-point/tags.txt
new file mode 100644 (file)
index 0000000..ede10ab
--- /dev/null
@@ -0,0 +1 @@
+math
index 2ca743dad0f4296ac123cc1d5cddf6568e70a12e..bedd3fd480f4cbcb7258e4fc0e6bc6f8369b5551 100644 (file)
@@ -4,8 +4,8 @@ USING: accessors arrays classes.singleton columns combinators
 combinators.short-circuit combinators.smart formatting fry
 grouping kernel locals math math.bits math.functions math.order
 math.private math.ranges math.statistics math.vectors
-math.vectors.private sequences sequences.deep sequences.extras
-sequences.private slots.private summary ;
+math.vectors.private sequences sequences.deep sequences.private
+slots.private summary ;
 IN: math.matrices
 
 ! defined here because of issue #1943
diff --git a/basis/math/trig/tags.txt b/basis/math/trig/tags.txt
new file mode 100644 (file)
index 0000000..ede10ab
--- /dev/null
@@ -0,0 +1 @@
+math
diff --git a/basis/math/trig/trig.factor b/basis/math/trig/trig.factor
new file mode 100644 (file)
index 0000000..515d7c7
--- /dev/null
@@ -0,0 +1,7 @@
+! Copyright (C) 2008 Eduardo Cavazos.
+! See http://factorcode.org/license.txt for BSD license.
+USING: math math.constants ;
+IN: math.trig
+
+: deg>rad ( x -- y ) pi * 180 / ; inline
+: rad>deg ( x -- y ) 180 * pi / ; inline
diff --git a/basis/method-chains/authors.txt b/basis/method-chains/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/basis/method-chains/method-chains-docs.factor b/basis/method-chains/method-chains-docs.factor
new file mode 100644 (file)
index 0000000..77b3dc7
--- /dev/null
@@ -0,0 +1,23 @@
+! Copyright (C) 2009 Joe Groff.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: method-chains
+
+HELP: AFTER:
+{ $syntax "AFTER: class generic
+    implementation ;" }
+{ $description "Defines a method on " { $snippet "generic" } " for " { $snippet "class" } " which executes the new " { $snippet "implementation" } " code after invoking the parent class method on " { $snippet "generic" } "." } ;
+
+HELP: BEFORE:
+{ $syntax "BEFORE: class generic
+    implementation ;" }
+{ $description "Defines a method on " { $snippet "generic" } " for " { $snippet "class" } " which executes the new " { $snippet "implementation" } " code, then invokes the parent class method on " { $snippet "generic" } "." } ;
+
+ARTICLE: "method-chains" "Method chaining syntax"
+"The " { $vocab-link "method-chains" } " vocabulary provides syntax for extending method implementations in class hierarchies."
+{ $subsections
+    POSTPONE: AFTER:
+    POSTPONE: BEFORE:
+} ;
+
+ABOUT: "method-chains"
diff --git a/basis/method-chains/method-chains-tests.factor b/basis/method-chains/method-chains-tests.factor
new file mode 100644 (file)
index 0000000..bfc4d6f
--- /dev/null
@@ -0,0 +1,13 @@
+IN: method-chains.tests
+USING: method-chains tools.test arrays strings sequences kernel namespaces ;
+
+GENERIC: testing ( a b -- c )
+
+M: sequence testing nip reverse ;
+AFTER: string testing append ;
+BEFORE: array testing over prefix "a" set ;
+
+{ V{ 3 2 1 } } [ 3 V{ 1 2 3 } testing ] unit-test
+{ "heyyeh" } [ 4 "yeh" testing ] unit-test
+{ { 4 2 0 } } [ 5 { 0 2 4 } testing ] unit-test
+{ { 5 0 2 4 } } [ "a" get ] unit-test
diff --git a/basis/method-chains/method-chains.factor b/basis/method-chains/method-chains.factor
new file mode 100644 (file)
index 0000000..5d24311
--- /dev/null
@@ -0,0 +1,7 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel generic generic.parser words fry ;
+IN: method-chains
+
+SYNTAX: AFTER: (M:) dupd '[ [ _ (call-next-method) ] _ bi ] define ;
+SYNTAX: BEFORE: (M:) over '[ _ [ _ (call-next-method) ] bi ] define ;
diff --git a/basis/method-chains/summary.txt b/basis/method-chains/summary.txt
new file mode 100644 (file)
index 0000000..dc80f82
--- /dev/null
@@ -0,0 +1 @@
+BEFORE: and AFTER: syntax for extending methods in class hierarchies
index b96a51699a528bb70c70b75fe45276bba5775e23..95f447a9576f783a1baa4f11aea106d2bb87ec67 100644 (file)
@@ -47,3 +47,7 @@ IN: sequences.deep.tests
         dup integer? [ even? [ 1 + ] when ] [ drop ] if
     ] deep-reduce
 ] unit-test
+
+{ V{ 1 } } [ 1 flatten1 ] unit-test
+{ { 1 2 3 } } [ { 1 2 3 } flatten1 ] unit-test
+{ { 1 2 3 { { 4 } } } } [ { 1 { 2 } { 3 { { 4 } } } } flatten1 ] unit-test
index e4edd80685ecf5096a58a884f7607c7b9daf8d05..36911bc12b8e9441c7ad7a432aa9617a19a0e6ba 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007, 2008 Daniel Ehrenberg, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequences kernel strings math fry ;
+USING: fry kernel make math sequences strings ;
 IN: sequences.deep
 
 ! All traversal goes in postorder
@@ -69,3 +69,12 @@ M: object branch? drop f ;
 
 : flatten-as ( obj exemplar -- seq )
     [ branch? ] swap deep-reject-as ;
+
+: flatten1 ( obj -- seq )
+    [
+        [
+            dup branch? [
+                [ dup branch? [ % ] [ , ] if ] each
+            ] [ , ] if
+        ]
+    ] keep dup branch? [ drop f ] unless make ;
diff --git a/basis/tools/which/authors.txt b/basis/tools/which/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/basis/tools/which/which-docs.factor b/basis/tools/which/which-docs.factor
new file mode 100644 (file)
index 0000000..4a8b809
--- /dev/null
@@ -0,0 +1,10 @@
+! Copyright (C) 2013 John Benediktsson.
+! See http://factorcode.org/license.txt for BSD license.
+
+USING: help.markup help.syntax kernel strings ;
+
+IN: tools.which
+
+HELP: which
+{ $values { "command" string } { "file/f" "the first matching path or " { $link f } } }
+{ $description "Returns the full path of the executable that would have been executed if " { $snippet "command" } " had been entered at the shell prompt." } ;
diff --git a/basis/tools/which/which.factor b/basis/tools/which/which.factor
new file mode 100644 (file)
index 0000000..4077002
--- /dev/null
@@ -0,0 +1,50 @@
+! Copyright (C) 2012 John Benediktsson
+! See http://factorcode.org/license.txt for BSD license
+
+USING: arrays assocs combinators.short-circuit command-line
+environment io io.backend io.files io.files.info io.pathnames
+kernel namespaces sequences sets splitting system unicode ;
+
+IN: tools.which
+
+<PRIVATE
+
+: executable? ( path -- ? )
+    {
+        [ exists? ]
+        [ file-executable? ]
+        [ file-info directory? not ]
+    } 1&& ;
+
+: split-path ( paths -- seq )
+    os windows? ";" ":" ? split harvest ;
+
+: path-extensions ( command -- commands )
+    "PATHEXT" os-env [
+        split-path 2dup [ [ >lower ] bi@ tail? ] with any?
+        [ drop 1array ] [ [ append ] with map ] if
+    ] [ 1array ] if* ;
+
+: find-which ( commands paths -- file/f )
+    [ normalize-path ] map members
+    cartesian-product flip concat
+    [ prepend-path ] { } assoc>map
+    [ executable? ] find nip ;
+
+: (which) ( command path -- file/f )
+    split-path os windows? [
+        [ path-extensions ] [ "." prefix ] bi*
+    ] [ [ 1array ] dip ] if find-which ;
+
+PRIVATE>
+
+: which ( command -- file/f )
+    "PATH" os-env (which) ;
+
+: ?which ( command -- file/command )
+    [ which ] [ or ] bi ;
+
+: run-which ( -- )
+    command-line get [ which [ print ] when* ] each ;
+
+MAIN: run-which
index f91ad6aa23212020eedc0310e832d23072a42eee..b7c3c2dc3c247c663a96d13f1c3c79ff79c0c8fe 100644 (file)
@@ -9,8 +9,8 @@ IN: cli.git
 SYMBOL: cli-git-num-parallel
 cli-git-num-parallel [ cpus 2 * ] initialize
 
-: git-command>string ( quot -- string )
-    utf8 <process-reader> stream-contents [ blank? ] trim-tail ;
+: git-command>string ( desc -- string )
+    process-contents [ blank? ] trim-tail ;
 
 : git-clone-as ( uri path -- process ) [ { "git" "clone" } ] 2dip 2array append run-process ;
 : git-clone ( uri -- process ) [ { "git" "clone" } ] dip suffix run-process ;
diff --git a/extra/couchdb/authors.txt b/extra/couchdb/authors.txt
deleted file mode 100644 (file)
index e9c193b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Alex Chapman
diff --git a/extra/couchdb/couchdb-tests.factor b/extra/couchdb/couchdb-tests.factor
deleted file mode 100644 (file)
index 3cb84d5..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-! Copyright (C) 2008 Alex Chapman
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs couchdb hashtables kernel namespaces
-random.data sequences strings tools.test ;
-IN: couchdb.tests
-
-! You must have a CouchDB server (currently only the version from svn will
-! work) running on localhost and listening on the default port for these tests
-! to work.
-
-<default-server> "factor-test" <db> [
-    [ ] [ couch get ensure-db ] unit-test
-    [ couch get create-db ] must-fail
-    [ ] [ couch get delete-db ] unit-test
-    [ couch get delete-db ] must-fail
-    [ ] [ couch get ensure-db ] unit-test
-    [ ] [ couch get ensure-db ] unit-test
-    [ 0 ] [ couch get db-info "doc_count" of ] unit-test
-    [ ] [ couch get compact-db ] unit-test
-    [ t ] [ couch get server>> next-uuid string? ] unit-test
-    [ ] [ H{
-            { "Subject" "I like Planktion" }
-            { "Tags" { "plankton" "baseball" "decisions" } }
-            { "Body"
-              "I decided today that I don't like baseball. I like plankton." }
-            { "Author" "Rusty" }
-            { "PostedDate" "2006-08-15T17:30:12Z-04:00" }
-           } save-doc ] unit-test
-    [ t ] [ couch get all-docs "rows" of first "id" of dup "id" set string? ] unit-test
-    [ t ] [ "id" get dup load-doc id> = ] unit-test
-    [ ] [ "id" get load-doc save-doc ] unit-test
-    [ "Rusty" ] [ "id" get load-doc "Author" of ] unit-test
-    [ ] [ "id" get load-doc "Alex" "Author" pick set-at save-doc ] unit-test
-    [ "Alex" ] [ "id" get load-doc "Author" of ] unit-test
-    [ 1 ] [ "function(doc) { emit(null, doc) }" temp-view-map "total_rows" of ] unit-test
-    [ ] [ H{
-         { "_id" "_design/posts" }
-         { "language" "javascript" }
-         { "views" H{
-             { "all" H{ { "map" "function(doc) { emit(null, doc) }" } } }
-           }
-         }
-       } save-doc ] unit-test
-    [ t ] [ "id" get load-doc delete-doc string? ] unit-test
-    [ "id" get load-doc ] must-fail
-
-    { t } [
-        "oga" "boga" associate
-        couch get db-url 10 random-string append
-        couch-put "ok" of
-    ] unit-test
-
-    [ ] [ couch get delete-db ] unit-test
-] with-couch
diff --git a/extra/couchdb/couchdb.factor b/extra/couchdb/couchdb.factor
deleted file mode 100644 (file)
index 15db192..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-! Copyright (C) 2008, 2009 Alex Chapman
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs continuations debugger fry hashtables http
-http.client io io.encodings.string io.encodings.utf8 json.reader
-json.writer kernel locals make math math.parser namespaces sequences
-strings urls.encoding vectors ;
-IN: couchdb
-
-! NOTE: This code only works with the latest couchdb (0.9.*), because old
-! versions didn't provide the /_uuids feature which this code relies on when
-! creating new documents.
-
-SYMBOL: couch
-: with-couch ( db quot -- )
-    couch swap with-variable ; inline
-
-! errors
-TUPLE: couchdb-error { data assoc } ;
-C: <couchdb-error> couchdb-error
-
-M: couchdb-error error. ( error -- )
-    "CouchDB Error: " write data>>
-    "error" over at [ print ] when*
-    "reason" of [ print ] when* ;
-
-PREDICATE: file-exists-error < couchdb-error
-    data>> "error" of "file_exists" = ;
-
-! http tools
-: couch-http-request ( request -- data )
-    [ http-request ] [
-        dup download-failed? [
-            response>> body>> json> <couchdb-error> throw
-        ] [
-            rethrow
-        ] if
-    ] recover nip ;
-
-: couch-request ( request -- assoc )
-    couch-http-request json> ;
-
-: couch-get ( url -- assoc )
-    <get-request> couch-request ;
-
-: <json-post-data> ( assoc -- post-data )
-    >json utf8 encode "application/json" <post-data> swap >>data ;
-
-: couch-put ( assoc url -- assoc' )
-    [ <json-post-data> ] dip <put-request> couch-request ;
-
-: couch-post ( assoc url -- assoc' )
-    [ <json-post-data> ] dip <post-request> couch-request ;
-
-: couch-delete ( url -- assoc )
-    <delete-request> couch-request ;
-
-: response-ok ( assoc -- assoc )
-    "ok" over delete-at* and t assert= ;
-
-: response-ok* ( assoc -- )
-    response-ok drop ;
-
-! server
-TUPLE: server { host string } { port integer } { uuids vector } { uuids-to-cache integer } ;
-
-CONSTANT: default-couch-host "localhost"
-CONSTANT: default-couch-port 5984
-CONSTANT: default-uuids-to-cache 100
-
-: <server> ( host port -- server )
-    V{ } clone default-uuids-to-cache server boa ;
-
-: <default-server> ( -- server )
-    default-couch-host default-couch-port <server> ;
-
-: (server-url) ( server -- )
-    "http://" % [ host>> % ] [ CHAR: : , port>> number>string % ] bi CHAR: / , ; inline
-
-: server-url ( server -- url )
-    [ (server-url) ] "" make ;
-
-: all-dbs ( server -- dbs )
-    server-url "_all_dbs" append couch-get ;
-
-: uuids-url ( server -- url )
-    [ dup server-url % "_uuids?count=" % uuids-to-cache>> number>string % ] "" make ;
-
-: uuids-get ( server -- uuids )
-     uuids-url couch-get "uuids" of >vector ;
-
-: get-uuids ( server -- server )
-    dup uuids-get [ nip ] curry change-uuids ;
-
-: ensure-uuids ( server -- server )
-    dup uuids>> empty? [ get-uuids ] when ;
-
-: next-uuid ( server -- uuid )
-    ensure-uuids uuids>> pop ;
-
-! db
-TUPLE: db { server server } { name string } ;
-C: <db> db
-
-: (db-url) ( db -- )
-    [ server>> server-url % ] [ name>> % ] bi CHAR: / , ; inline
-
-: db-url ( db -- url )
-    [ (db-url) ] "" make ;
-
-: create-db ( db -- )
-    f swap db-url couch-put response-ok* ;
-
-: ensure-db ( db -- )
-    '[ _ create-db ] [ file-exists-error? ] ignore-error ;
-
-: delete-db ( db -- )
-    db-url couch-delete drop ;
-
-: db-info ( db -- info )
-    db-url couch-get ;
-
-: all-docs ( db -- docs )
-    ! TODO: queries. Maybe pass in a hashtable with options
-    db-url "_all_docs" append couch-get ;
-
-: compact-db ( db -- )
-    f swap db-url "_compact" append couch-post response-ok* ;
-
-! documents
-: id> ( assoc -- id ) "_id" of ;
-: >id ( assoc id -- assoc ) "_id" pick set-at ;
-: rev> ( assoc -- rev ) "_rev" of ;
-: >rev ( assoc rev -- assoc ) "_rev" pick set-at ;
-: attachments> ( assoc -- attachments ) "_attachments" of ;
-: >attachments ( assoc attachments -- assoc ) "_attachments" pick set-at ;
-
-:: copy-key ( to from to-key from-key -- )
-    from-key from at
-    to-key to set-at ;
-
-: copy-id ( to from -- )
-    "_id" "id" copy-key ;
-
-: copy-rev ( to from -- )
-    "_rev" "rev" copy-key ;
-
-: id-url ( id -- url )
-    couch get db-url swap url-encode-full append ;
-
-: doc-url ( assoc -- url )
-    id> id-url ;
-
-: temp-view ( view -- results )
-    couch get db-url "_temp_view" append couch-post ;
-
-: temp-view-map ( map -- results )
-    "map" associate temp-view ;
-
-: save-doc-as ( assoc id -- )
-    dupd id-url couch-put response-ok
-    [ copy-id ] [ copy-rev ] 2bi ;
-
-: save-new-doc ( assoc -- )
-    couch get server>> next-uuid save-doc-as ;
-
-: save-doc ( assoc -- )
-    dup id> [ save-doc-as ] [ save-new-doc ] if* ;
-
-: load-doc ( id -- assoc )
-    id-url couch-get ;
-
-: delete-doc ( assoc -- deletion-revision )
-    [
-        [ doc-url % ]
-        [ "?rev=" % "_rev" of % ] bi
-    ] "" make couch-delete response-ok "rev" of ;
-
-: remove-keys ( assoc keys -- )
-    swap [ delete-at ] curry each ;
-
-: remove-couch-info ( assoc -- )
-    { "_id" "_rev" "_attachments" } remove-keys ;
-
-! : construct-attachment ( content-type data -- assoc )
-!     H{ } clone "name" pick set-at "content-type" pick set-at ;
-!
-! : add-attachment ( assoc name attachment -- )
-!     pick attachments> [ H{ } clone ] unless*
-!
-! : attach ( assoc name content-type data -- )
-!     construct-attachment H{ } clone
-
-! TODO:
-! - startkey, limit, descending, etc.
-! - loading specific revisions
-! - views
-! - attachments
-! - bulk insert/update
-! - ...?
diff --git a/extra/couchdb/tags.txt b/extra/couchdb/tags.txt
deleted file mode 100644 (file)
index fc7cc1c..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-not tested
-database
diff --git a/extra/math/floating-point/authors.txt b/extra/math/floating-point/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/math/floating-point/floating-point-tests.factor b/extra/math/floating-point/floating-point-tests.factor
deleted file mode 100644 (file)
index b1f0864..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test math.floating-point kernel
-math.constants fry sequences math random ;
-IN: math.floating-point.tests
-
-{ t } [ pi >double< >double pi = ] unit-test
-{ t } [ -1.0 >double< >double -1.0 = ] unit-test
-
-{ t } [ 1/0. infinity? ] unit-test
-{ t } [ -1/0. infinity? ] unit-test
-{ f } [ 0/0. infinity? ] unit-test
-{ f } [ 10. infinity? ] unit-test
-{ f } [ -10. infinity? ] unit-test
-{ f } [ 0. infinity? ] unit-test
-
-{ 0 } [ 0.0 double>ratio ] unit-test
-{ 1 } [ 1.0 double>ratio ] unit-test
-{ 1/2 } [ 0.5 double>ratio ] unit-test
-{ 3/4 } [ 0.75 double>ratio ] unit-test
-{ 12+1/2 } [ 12.5 double>ratio ] unit-test
-{ -12-1/2 } [ -12.5 double>ratio ] unit-test
-{ 3+39854788871587/281474976710656 } [ pi double>ratio ] unit-test
-
-: roundtrip ( n -- )
-    [ '[ _ ] ] keep '[ _ double>ratio >float ] unit-test ;
-
-{ 1 12 123 1234 } [ bits>double roundtrip ] each
-
-100 [ -10.0 10.0 uniform-random-float roundtrip ] times
diff --git a/extra/math/floating-point/floating-point.factor b/extra/math/floating-point/floating-point.factor
deleted file mode 100644 (file)
index a3e6f2d..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math sequences prettyprint math.parser io
-math.functions math.bitwise combinators.short-circuit ;
-IN: math.floating-point
-
-: (double-sign) ( bits -- n ) -63 shift ; inline
-: double-sign ( double -- n ) double>bits (double-sign) ;
-
-: (double-exponent-bits) ( bits -- n )
-    -52 shift 11 on-bits mask ; inline
-
-: double-exponent-bits ( double -- n )
-    double>bits (double-exponent-bits) ;
-
-: (double-mantissa-bits) ( double -- n )
-    52 on-bits mask ;
-
-: double-mantissa-bits ( double -- n )
-    double>bits (double-mantissa-bits) ;
-
-: >double ( S E M -- frac )
-    [ 52 shift ] dip
-    [ 63 shift ] 2dip bitor bitor bits>double ;
-
-: >double< ( double -- S E M )
-    double>bits
-    [ (double-sign) ]
-    [ (double-exponent-bits) ]
-    [ (double-mantissa-bits) ] tri ;
-
-: double. ( double -- )
-    double>bits
-    [ (double-sign) .b ]
-    [ (double-exponent-bits) >bin 11 CHAR: 0 pad-head bl print ]
-    [
-        (double-mantissa-bits) >bin 52 CHAR: 0 pad-head
-        11 [ bl ] times print
-    ] tri ;
-
-: infinity? ( double -- ? )
-    double>bits
-    {
-        [ (double-exponent-bits) 11 on-bits = ]
-        [ (double-mantissa-bits) 0 = ]
-    } 1&& ;
-
-: check-special ( n -- n )
-    dup fp-special? [ "cannot be special" throw ] when ;
-
-: double>ratio ( double -- a/b )
-    check-special double>bits
-    [ (double-sign) zero? 1 -1 ? ]
-    [ (double-mantissa-bits) 52 2^ / ]
-    [ (double-exponent-bits) ] tri
-    [ 1 ] [ [ 1 + ] dip ] if-zero 1023 - 2 swap ^ * * ;
diff --git a/extra/math/floating-point/tags.txt b/extra/math/floating-point/tags.txt
deleted file mode 100644 (file)
index ede10ab..0000000
+++ /dev/null
@@ -1 +0,0 @@
-math
diff --git a/extra/math/trig/tags.txt b/extra/math/trig/tags.txt
deleted file mode 100644 (file)
index ede10ab..0000000
+++ /dev/null
@@ -1 +0,0 @@
-math
diff --git a/extra/math/trig/trig.factor b/extra/math/trig/trig.factor
deleted file mode 100644 (file)
index 515d7c7..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-! Copyright (C) 2008 Eduardo Cavazos.
-! See http://factorcode.org/license.txt for BSD license.
-USING: math math.constants ;
-IN: math.trig
-
-: deg>rad ( x -- y ) pi * 180 / ; inline
-: rad>deg ( x -- y ) 180 * pi / ; inline
diff --git a/extra/method-chains/authors.txt b/extra/method-chains/authors.txt
deleted file mode 100644 (file)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/extra/method-chains/method-chains-docs.factor b/extra/method-chains/method-chains-docs.factor
deleted file mode 100644 (file)
index 77b3dc7..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-! Copyright (C) 2009 Joe Groff.
-! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax ;
-IN: method-chains
-
-HELP: AFTER:
-{ $syntax "AFTER: class generic
-    implementation ;" }
-{ $description "Defines a method on " { $snippet "generic" } " for " { $snippet "class" } " which executes the new " { $snippet "implementation" } " code after invoking the parent class method on " { $snippet "generic" } "." } ;
-
-HELP: BEFORE:
-{ $syntax "BEFORE: class generic
-    implementation ;" }
-{ $description "Defines a method on " { $snippet "generic" } " for " { $snippet "class" } " which executes the new " { $snippet "implementation" } " code, then invokes the parent class method on " { $snippet "generic" } "." } ;
-
-ARTICLE: "method-chains" "Method chaining syntax"
-"The " { $vocab-link "method-chains" } " vocabulary provides syntax for extending method implementations in class hierarchies."
-{ $subsections
-    POSTPONE: AFTER:
-    POSTPONE: BEFORE:
-} ;
-
-ABOUT: "method-chains"
diff --git a/extra/method-chains/method-chains-tests.factor b/extra/method-chains/method-chains-tests.factor
deleted file mode 100644 (file)
index bfc4d6f..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-IN: method-chains.tests
-USING: method-chains tools.test arrays strings sequences kernel namespaces ;
-
-GENERIC: testing ( a b -- c )
-
-M: sequence testing nip reverse ;
-AFTER: string testing append ;
-BEFORE: array testing over prefix "a" set ;
-
-{ V{ 3 2 1 } } [ 3 V{ 1 2 3 } testing ] unit-test
-{ "heyyeh" } [ 4 "yeh" testing ] unit-test
-{ { 4 2 0 } } [ 5 { 0 2 4 } testing ] unit-test
-{ { 5 0 2 4 } } [ "a" get ] unit-test
diff --git a/extra/method-chains/method-chains.factor b/extra/method-chains/method-chains.factor
deleted file mode 100644 (file)
index 5d24311..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel generic generic.parser words fry ;
-IN: method-chains
-
-SYNTAX: AFTER: (M:) dupd '[ [ _ (call-next-method) ] _ bi ] define ;
-SYNTAX: BEFORE: (M:) over '[ _ [ _ (call-next-method) ] bi ] define ;
diff --git a/extra/method-chains/summary.txt b/extra/method-chains/summary.txt
deleted file mode 100644 (file)
index dc80f82..0000000
+++ /dev/null
@@ -1 +0,0 @@
-BEFORE: and AFTER: syntax for extending methods in class hierarchies
index 762660f9cf84482b87d91e97df1bc4a544154ae3..a85b6c087e8538a4f8f17523009a82fbce4f5e1c 100644 (file)
@@ -202,10 +202,6 @@ tools.test vectors vocabs ;
 { { 1 0 0 1 0 0 0 1 0 0 } }
 [ 1 { 0 3 7 } 10 0 <array> [ set-nths-unsafe ] keep ] unit-test
 
-{ V{ 1 } } [ 1 flatten1 ] unit-test
-{ { 1 2 3 } } [ { 1 2 3 } flatten1 ] unit-test
-{ { 1 2 3 { { 4 } } } } [ { 1 { 2 } { 3 { { 4 } } } } flatten1 ] unit-test
-
 { t 3 3 } [ 10 <iota> [ [ odd? ] [ 1 > ] bi* and ] map-find-index ] unit-test
 { f f f } [ 10 <iota> [ [ odd? ] [ 9 > ] bi* and ] map-find-index ] unit-test
 
index 26b343bc7bb96b303192d0858bf1d242252e1493..45bc1ecd7f4d741b23e74b9059bd20d9661d4f9f 100644 (file)
@@ -481,15 +481,6 @@ PRIVATE>
 : set-nths-unsafe ( value indices seq -- )
     swapd '[ _ swap _ set-nth-unsafe ] each ; inline
 
-: flatten1 ( obj -- seq )
-    [
-        [
-            dup branch? [
-                [ dup branch? [ % ] [ , ] if ] each
-            ] [ , ] if
-        ]
-    ] keep dup branch? [ drop f ] unless make ;
-
 <PRIVATE
 
 : (map-find-index) ( seq quot find-quot -- result i elt )
diff --git a/extra/tools/which/authors.txt b/extra/tools/which/authors.txt
deleted file mode 100644 (file)
index e091bb8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-John Benediktsson
diff --git a/extra/tools/which/which-docs.factor b/extra/tools/which/which-docs.factor
deleted file mode 100644 (file)
index 4a8b809..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-! Copyright (C) 2013 John Benediktsson.
-! See http://factorcode.org/license.txt for BSD license.
-
-USING: help.markup help.syntax kernel strings ;
-
-IN: tools.which
-
-HELP: which
-{ $values { "command" string } { "file/f" "the first matching path or " { $link f } } }
-{ $description "Returns the full path of the executable that would have been executed if " { $snippet "command" } " had been entered at the shell prompt." } ;
diff --git a/extra/tools/which/which.factor b/extra/tools/which/which.factor
deleted file mode 100644 (file)
index 4077002..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-! Copyright (C) 2012 John Benediktsson
-! See http://factorcode.org/license.txt for BSD license
-
-USING: arrays assocs combinators.short-circuit command-line
-environment io io.backend io.files io.files.info io.pathnames
-kernel namespaces sequences sets splitting system unicode ;
-
-IN: tools.which
-
-<PRIVATE
-
-: executable? ( path -- ? )
-    {
-        [ exists? ]
-        [ file-executable? ]
-        [ file-info directory? not ]
-    } 1&& ;
-
-: split-path ( paths -- seq )
-    os windows? ";" ":" ? split harvest ;
-
-: path-extensions ( command -- commands )
-    "PATHEXT" os-env [
-        split-path 2dup [ [ >lower ] bi@ tail? ] with any?
-        [ drop 1array ] [ [ append ] with map ] if
-    ] [ 1array ] if* ;
-
-: find-which ( commands paths -- file/f )
-    [ normalize-path ] map members
-    cartesian-product flip concat
-    [ prepend-path ] { } assoc>map
-    [ executable? ] find nip ;
-
-: (which) ( command path -- file/f )
-    split-path os windows? [
-        [ path-extensions ] [ "." prefix ] bi*
-    ] [ [ 1array ] dip ] if find-which ;
-
-PRIVATE>
-
-: which ( command -- file/f )
-    "PATH" os-env (which) ;
-
-: ?which ( command -- file/command )
-    [ which ] [ or ] bi ;
-
-: run-which ( -- )
-    command-line get [ which [ print ] when* ] each ;
-
-MAIN: run-which