]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 14 Jan 2010 23:22:02 +0000 (17:22 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 14 Jan 2010 23:22:02 +0000 (17:22 -0600)
Conflicts:
core/sequences/sequences-docs.factor

basis/math/complex/complex-tests.factor
basis/math/functions/functions.factor
build-support/factor.sh
core/generic/generic-docs.factor
core/math/parser/parser-docs.factor
core/parser/parser.factor
core/sequences/sequences-docs.factor
extra/mason/common/common.factor

index 4b0481eca1eb808d514736f37d97a4ed2fce8d1c..f85ec49f81d06e79b46dec824d18b8f9da1fcfa0 100644 (file)
@@ -70,4 +70,7 @@ IN: math.complex.tests
 [ ] [ C{ 1 4 } coth drop ] unit-test
 [ ] [ C{ 1 4 } cot drop ] unit-test
 
+[ t ] [ 0.0 pi rect> exp C{ -1 0 } 1.0e-7 ~ ] unit-test
+[ t ] [ 0 pi rect> exp C{ -1 0 } 1.0e-7 ~ ] unit-test
+
 [ "C{ 1/2 2/3 }" ] [ C{ 1/2 2/3 } unparse ] unit-test
index d91b4b6b92a0c5904d418037be7a6999e573322c..a1466dd22cb587415a694cbf31b57517c2e8d67b 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math kernel math.constants math.private math.bits
 math.libm combinators math.order sequences ;
@@ -62,7 +62,7 @@ M: float exp fexp ; inline
 
 M: real exp >float exp ; inline
 
-M: complex exp >rect swap fexp swap polar> ; inline
+M: complex exp >rect swap exp swap polar> ; inline
 
 <PRIVATE
 
index 2f8745aeef878c13aaf1a57fdde04dfe0703fb10..c2775f435afb114d67af0f1123ce340f46a7237c 100755 (executable)
@@ -25,9 +25,9 @@ test_program_installed() {
 
 exit_script() {
     if [[ $FIND_MAKE_TARGET -eq true ]] ; then
-               echo $MAKE_TARGET;
-       fi
-       exit $1
+        echo $MAKE_TARGET;
+    fi
+    exit $1
 }
 
 ensure_program_installed() {
@@ -347,7 +347,7 @@ update_script_name() {
 
 update_script() {
     update_script=`update_script_name`
-       bash_path=`which bash`
+    bash_path=`which bash`
     echo "#!$bash_path" >"$update_script"
     echo "git pull \"$GIT_URL\" master" >>"$update_script"
     echo "if [[ \$? -eq 0 ]]; then exec \"$0\" $SCRIPT_ARGS; else echo \"git pull failed\"; exit 2; fi" \
@@ -433,7 +433,7 @@ make_factor() {
 update_boot_images() {
     echo "Deleting old images..."
     $DELETE checksums.txt* > /dev/null 2>&1
-       # delete boot images with one or two characters after the dot
+    # delete boot images with one or two characters after the dot
     $DELETE $BOOT_IMAGE.{?,??} > /dev/null 2>&1
     $DELETE temp/staging.*.image > /dev/null 2>&1
     if [[ -f $BOOT_IMAGE ]] ; then
index dea523538eec6384d9b51179269d4c2e22d3581b..240fdd96e0aab3c1a3a899adabe8baa3f182fed7 100644 (file)
@@ -11,15 +11,13 @@ $nl
 { $code
     "GENERIC: explain ( object -- )"
     "M: object explain drop \"an object\" print ;"
-    "M: number explain drop \"a number\" print ;"
-    "M: sequence explain drop \"a sequence\" print ;"
+    "M: generic explain drop \"a class word\" print ;"
+    "M: class explain drop \"a generic word\" print ;"
 }
 "The linear order is the following, from least-specific to most-specific:"
-{ $code "{ object sequence number }" }
-"Neither " { $link number } " nor " { $link sequence } " are subclasses of each other, yet their intersection is the non-empty " { $link integer } " class. Calling " { $snippet "explain" } " with an integer on the stack will print " { $snippet "a number" } " because " { $link number } " precedes " { $link sequence } " in the class linearization order. If this was not the desired outcome, define a method on the intersection:"
-{ $code "M: integer explain drop \"an integer\" print ;" }
-"Now, the linear order is the following, from least-specific to most-specific:"
-{ $code "{ object sequence number integer }" }
+{ $code "{ object generic class }" }
+"Neither " { $link class } " nor " { $link generic } " are subclasses of each other, and their intersection is non-empty. Calling " { $snippet "explain" } " with a word on the stack that is both a class and a generic word will print " { $snippet "a generic word" } " because " { $link class } " precedes " { $link generic } " in the class linearization order. (One example of a word which is both a class and a generic word is the class of classes, " { $link class } ", which is also a word to get the class of an object.)"
+$nl
 "The " { $link order } " word can be useful to clarify method dispatch order:"
 { $subsections order } ;
 
index cd0bb47bd5b39bd2a06d760c2f9d2969074eb2c8..0d039f2fe97bc2e6f5e09c0182018d237cef3af2 100644 (file)
@@ -29,12 +29,12 @@ $nl
 ABOUT: "number-strings"
 
 HELP: digits>integer
-{ $values { "seq" "a sequence of integers" } { "radix" "an integer between 2 and 36" } { "n/f" { $maybe integer } } }
+{ $values { "seq" "a sequence of integers" } { "radix" "an integer between 2 and 16" } { "n/f" { $maybe integer } } }
 { $description "Converts a sequence of digits (with most significant digit first) into an integer." }
 { $notes "This is one of the factors of " { $link string>number } "." } ;
 
 HELP: >digit
-{ $values { "n" "an integer between 0 and 35" } { "ch" "a character" } }
+{ $values { "n" "an integer between 0 and 15" } { "ch" "a character" } }
 { $description "Outputs a character representation of a digit." }
 { $notes "This is one of the factors of " { $link number>string } "." } ;
 
@@ -44,7 +44,7 @@ HELP: digit>
 { $notes "This is one of the factors of " { $link string>number } "." } ;
 
 HELP: base>
-{ $values { "str" string } { "radix" "an integer between 2 and 36" } { "n/f" "a real number or " { $link f } } }
+{ $values { "str" string } { "radix" "an integer between 2 and 16" } { "n/f" "a real number or " { $link f } } }
 { $description "Creates a real number from a string representation with the given radix. The radix is ignored for floating point literals; they are always taken to be in base 10."
 $nl
 "Outputs " { $link f } " if the string does not represent a number." } ;
@@ -84,7 +84,7 @@ $nl
 { >hex POSTPONE: HEX: hex> .h } related-words
 
 HELP: >base
-{ $values { "n" real } { "radix" "an integer between 2 and 36" } { "str" string } }
+{ $values { "n" real } { "radix" "an integer between 2 and 16" } { "str" string } }
 { $description "Converts a real number into a string representation using the given radix. If the number is a float, the radix is ignored and the output is always in base 10." } ;
 
 HELP: >bin
index d920e1fc734767adfc95c518d4688a8c59478fd8..1433289f0a59fd8c02cd2e9c81ce34f32783647c 100644 (file)
@@ -55,8 +55,11 @@ ERROR: staging-violation word ;
     execute( accum -- accum ) ;
 
 : scan-object ( -- object )
-    scan-word dup parsing-word?
-    [ V{ } clone swap execute-parsing first ] when ;
+    scan-word {
+        { [ dup not ] [ unexpected-eof ] }
+        { [ dup parsing-word? ] [ V{ } clone swap execute-parsing first ] }
+        [ ]
+    } cond  ;
 
 : parse-step ( accum end -- accum ? )
     scan-word {
index a33aaa21d26e565b0c171e61376f9f6d1ff402de..9f570f97d5af49645c975d0b328f05c8fadbafea 100644 (file)
@@ -1409,16 +1409,21 @@ ARTICLE: "virtual-sequences" "Virtual sequences"
 "A virtual sequence is an implementation of the " { $link "sequence-protocol" } " which does not store its own elements, and instead computes them, either from scratch or by retrieving them from another sequence."
 $nl
 "Implementations include the following:"
-{ $subsections reversed slice iota }
-"Virtual sequences can be implemented with the " { $link "virtual-sequences-protocol" } ", by translating an index in the virtual sequence into an index in another sequence." ;
+{ $subsections reversed slice }
+"Virtual sequences can be implemented with the " { $link "virtual-sequences-protocol" } ", by translating an index in the virtual sequence into an index in another sequence."
+{ $see-also "sequences-integers" } ;
 
 ARTICLE: "sequences-integers" "Counted loops"
-"Integers do not support the sequence protocol, but can be turned into virtual sequences using the " { $link iota } " word. For example, the integer 3, when wrapped in an " { $link iota } ", contains the elements 0, 1, and 2. This is very useful for performing counted loops. Note that since this is a virtual sequence, the elements of the sequence are not actually stored, but calculated on demand."
+"A virtual sequence is defined for iterating over integers from zero."
+{ $subsection iota }
+"For example, calling " { $link iota } " on the integer 3 produces a sequence containing the elements 0, 1, and 2. This is very useful for performing counted loops."
 $nl
-"As another example, the " { $link each } " combinator, given a sequence, simply calls a quotation on each element of the sequence, ranging from 0 up to the integer wrapped by iota:"
+"This means the " { $link each } " combinator, given an integer, simply calls a quotation that number of times, pushing a counter on each iteration that ranges from 0 up to that integer:"
 { $example "3 iota [ . ] each" "0\n1\n2" }
 "A common idiom is to iterate over a sequence, while also maintaining a loop counter. This can be done using " { $link each-index } ", " { $link map-index } " and " { $link reduce-index } "."
 $nl
+"Combinators that produce new sequences, such as " { $link map } ", will output an array if the input is an instance of " { $link iota } "."
+$nl
 "More elaborate counted loops can be performed with " { $link "math.ranges" } "." ;
 
 ARTICLE: "sequences-if" "Control flow with sequences"
index e77dacaf580bc2a3a23c3a085e4ef553d79cc20a..cac4180abd53c74a44a3e904c9d13980497f531d 100644 (file)
@@ -30,6 +30,7 @@ M: windows really-delete-tree
 M: unix really-delete-tree delete-tree ;
 
 : retry ( n quot -- )
+    [ iota ] dip
     '[ drop @ f ] attempt-all drop ; inline
 
 :: upload-safely ( local username host remote -- )