From a615700af1f6d969b394ba8ea6a451025df2a7c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Tue, 20 Oct 2009 13:55:29 +0200 Subject: [PATCH 1/5] ui.tools.listener docs: typo --- basis/ui/tools/listener/listener-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/ui/tools/listener/listener-docs.factor b/basis/ui/tools/listener/listener-docs.factor index b762e036e6..966ac37d30 100644 --- a/basis/ui/tools/listener/listener-docs.factor +++ b/basis/ui/tools/listener/listener-docs.factor @@ -9,7 +9,7 @@ HELP: interactor $nl "Interactors are created by calling " { $link } "." $nl -"Interactors implement the " { $link stream-readln } ", " { $link stream-read } " and " { $link read-quot } " generic words." } ; +"Interactors implement the " { $link stream-readln } ", " { $link stream-read } " and " { $link stream-read-quot } " generic words." } ; ARTICLE: "ui-listener" "UI listener" "The graphical listener adds input history and word and vocabulary completion. See " { $link "listener" } " for general information on the listener." From db663548f9cd4615c31efa81b1b109a12ca2cfba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Wed, 21 Oct 2009 19:48:49 +0200 Subject: [PATCH 2/5] math: typo in rem docs --- core/math/math-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index 1e107124a2..6357c8bd98 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -212,7 +212,7 @@ HELP: recip HELP: rem { $values { "x" rational } { "y" rational } { "z" rational } } { $description - "Computes the remainder of dividing " { $snippet "x" } " by " { $snippet "y" } ", with the remainder always positive." + "Computes the remainder of dividing " { $snippet "x" } " by " { $snippet "y" } ", with the remainder always positive or zero." { $list "Given fixnums, always yields a fixnum." "Given bignums, always yields a bignum." From caf978588bf9521cde6a1d6d518c5954cb4d150e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Thu, 18 Feb 2010 18:18:26 +0100 Subject: [PATCH 3/5] sequences: clarify some stack effect and examlpes in docs --- core/sequences/sequences-docs.factor | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 38eadc745d..dc26933af4 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -269,7 +269,7 @@ HELP: reduce HELP: reduce-index { $values - { "seq" sequence } { "identity" object } { "quot" quotation } } + { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt index -- result )" } } } { $description "Combines successive elements of the sequence and their indices binary operations, and outputs the final result. On the first iteration, the three inputs to the quotation are " { $snippet "identity" } ", the first element of the sequence, and its index, 0. On successive iterations, the first input is the result of the previous iteration, the second input is the corresponding element of the sequence, and the third is its index." } { $examples { $example "USING: sequences prettyprint math ;" "{ 10 50 90 } 0 [ + + ] reduce-index ." @@ -321,20 +321,20 @@ HELP: map-as HELP: each-index { $values - { "seq" sequence } { "quot" quotation } } + { "seq" sequence } { "quot" { $quotation "( elt index -- )" } } } { $description "Calls the quotation with the element of the sequence and its index on the stack, with the index on the top of the stack." } -{ $examples { $example "USING: sequences prettyprint math ;" -"{ 10 20 30 } [ + . ] each-index" -"10\n21\n32" +{ $examples { $example "USING: arrays sequences prettyprint ;" +"{ 10 20 30 } [ 2array . ] each-index" +"{ 10 0 }\n{ 20 1 }\n{ 30 2 }" } } ; HELP: map-index { $values - { "seq" sequence } { "quot" quotation } { "newseq" sequence } } + { "seq" sequence } { "quot" { $quotation "( elt index -- result )" } } { "newseq" sequence } } { $description "Calls the quotation with the element of the sequence and its index on the stack, with the index on the top of the stack. Collects the outputs of the quotation and outputs them in a sequence of the same type as the input sequence." } -{ $examples { $example "USING: sequences prettyprint math ;" -"{ 10 20 30 } [ + ] map-index ." -"{ 10 21 32 }" +{ $examples { $example "USING: arrays sequences prettyprint ;" +"{ 10 20 30 } [ 2array ] map-index ." +"{ { 10 0 } { 20 1 } { 30 2 } }" } } ; HELP: change-nth @@ -995,8 +995,8 @@ HELP: count HELP: selector { $values - { "quot" "a predicate quotation" } - { "selector" quotation } { "accum" vector } } + { "quot" { $quotation "( elt -- ? )" } } + { "selector" { $quotation "( elt -- )" } } { "accum" vector } } { $description "Creates a new vector to accumulate the values which return true for a predicate. Returns a new quotation which accepts an object to be tested and stored in the collector if the test yields true. The collector is left on the stack for convenience." } { $example "! Find all the even numbers:" "USING: prettyprint sequences math kernel ;" "10 iota [ even? ] selector [ each ] dip ." @@ -1152,7 +1152,7 @@ HELP: replicate HELP: replicate-as { $values - { "len" integer } { "quot" quotation } { "exemplar" sequence } + { "len" integer } { "quot" { $quotation "( -- elt )" } } { "exemplar" sequence } { "newseq" sequence } } { $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new sequence of the same type as the exemplar sequence." } { $examples @@ -1190,7 +1190,7 @@ HELP: virtual@ HELP: 2map-reduce { $values - { "seq1" sequence } { "seq2" sequence } { "map-quot" quotation } { "reduce-quot" quotation } + { "seq1" sequence } { "seq2" sequence } { "map-quot" { $quotation "( elt1 elt2 -- intermediate )" } } { "reduce-quot" { $quotation "( prev intermediate -- result )" } } { "result" object } } { $description "Calls " { $snippet "map-quot" } " on each pair of elements from " { $snippet "seq1" } " and " { $snippet "seq2" } " and combines the results using " { $snippet "reduce-quot" } " in the same manner as " { $link reduce } ", except that there is no identity element, and the sequence must have a length of at least 1." } { $errors "Throws an error if the sequence is empty." } @@ -1236,7 +1236,7 @@ HELP: collector HELP: binary-reduce { $values - { "seq" sequence } { "start" integer } { "quot" quotation } + { "seq" sequence } { "start" integer } { "quot" { $quotation "( elt1 elt2 -- newelt )" } } { "value" object } } { $description "Like " { $link reduce } ", but splits the sequence in half recursively until each sequence is small enough, and calls the quotation on these smaller sequences. If the quotation computes values that depend on the size of their input, such as bignum arithmetic, then this algorithm can be more efficient than using " { $link reduce } "." } { $examples "Computing factorial:" @@ -1247,7 +1247,7 @@ HELP: binary-reduce HELP: follow { $values - { "obj" object } { "quot" quotation } + { "obj" object } { "quot" { $quotation "( prev -- result/f )" } } { "seq" sequence } } { $description "Outputs a sequence containing the input object and all of the objects generated by successively feeding the result of the quotation called on the input object to the quotation recursuively. Objects yielded by the quotation are added to the output sequence until the quotation yields " { $link f } ", at which point the recursion terminates." } { $examples "Get random numbers until zero is reached:" From eb8344a5a5494276e5f7d5f16372d87364e6bdd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Thu, 18 Feb 2010 18:43:13 +0100 Subject: [PATCH 4/5] assocs: doc fixes --- core/assocs/assocs-docs.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/assocs/assocs-docs.factor b/core/assocs/assocs-docs.factor index 0d5a884832..8f93c5a9d1 100644 --- a/core/assocs/assocs-docs.factor +++ b/core/assocs/assocs-docs.factor @@ -221,7 +221,7 @@ HELP: assoc-size HELP: assoc-like { $values { "assoc" assoc } { "exemplar" assoc } { "newassoc" "a new assoc" } } -{ $contract "Creates a new assoc having the same entries as "{ $snippet "assoc" } " and the same type as " { $snippet "exemplar" } "." } ; +{ $contract "Creates a new assoc having the same entries as " { $snippet "assoc" } " and the same type as " { $snippet "exemplar" } "." } ; HELP: assoc-empty? { $values { "assoc" assoc } { "?" "a boolean" } } @@ -383,7 +383,7 @@ HELP: cache { $side-effects "assoc" } ; HELP: 2cache -{ $values { "key1" "a key" } { "key2" "a key" } { "assoc" assoc } { "quot" { $quotation "( key -- value )" } } { "value" "a previously-retained or freshly-computed value" } } +{ $values { "key1" "a key" } { "key2" "a key" } { "assoc" assoc } { "quot" { $quotation "( key1 key2 -- value )" } } { "value" "a previously-retained or freshly-computed value" } } { $description "If a single key composed of the input keys is present in the assoc, outputs the associated value, otherwise calls the quotation to produce a value and stores the keys/value pair into the assoc. Returns the value stored in the assoc. Returns a value either looked up or newly stored in the assoc." } { $side-effects "assoc" } ; @@ -432,7 +432,7 @@ HELP: assoc-combine HELP: assoc-map-as { $values - { "assoc" assoc } { "quot" quotation } { "exemplar" assoc } + { "assoc" assoc } { "quot" { $quotation "( key value -- newkey newvalue )" } } { "exemplar" assoc } { "newassoc" assoc } } { $description "Applies the quotation to each entry in the input assoc and collects the results in a new assoc of the stame type as the exemplar." } { $examples { $example "USING: prettyprint assocs hashtables math ;" " H{ { 1 2 } { 3 4 } } [ sq ] { } assoc-map-as ." "{ { 1 4 } { 3 16 } }" } } ; From aec0243f8331f69f2c71804e312b58baca56252a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Thu, 18 Feb 2010 18:47:02 +0100 Subject: [PATCH 5/5] infix: part about integers as sequences doesn't apply anymore --- extra/infix/infix-docs.factor | 8 -------- 1 file changed, 8 deletions(-) diff --git a/extra/infix/infix-docs.factor b/extra/infix/infix-docs.factor index 9c42bf256b..3885fcc613 100644 --- a/extra/infix/infix-docs.factor +++ b/extra/infix/infix-docs.factor @@ -65,14 +65,6 @@ $nl "[let { 1 2 3 4 } :> myarr [infix myarr[4/2]*3 infix] ] ." "9" } -"Please note: in Factor " { $emphasis "fixnums are sequences too." } " If you are not careful with sequence accesses you may introduce subtle bugs:" -{ $example - "USING: arrays infix locals ;" - ":: add-2nd-elements ( x y -- res )" - " [infix x[1] + y[1] infix] ;" - "{ 1 2 3 } { 0 1 2 3 } add-2nd-elements ." - "3" -} ; ABOUT: "infix"