Collection.st
changeset 22321 9d2e84a333a0
parent 22306 1e4eace48bbd
child 22334 8e2e3cb23910
--- a/Collection.st	Sun Oct 22 22:31:56 2017 +0200
+++ b/Collection.st	Mon Oct 23 00:09:48 2017 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
               All Rights Reserved
@@ -1533,10 +1531,10 @@
 
 product
     "return the product of all elements which are supposed to be numeric.
-     Raises an error for an empty receiver."
-
-    ^ self 
-        fold:[:accum :each | accum * each].
+     Returns 1 for an empty receiver."
+
+    self isEmpty ifTrue:[^ 1].
+    ^ self fold:[:accum :each | accum * each].
 
     "
      TestCase should:[ Array new product ] raise:Error.
@@ -1545,6 +1543,8 @@
      TestCase assert:( #(6) product == 6).
      TestCase assert:( #(1 2 3 4 5) product = 5 factorial )
     "
+
+    "Modified: / 23-10-2017 / 00:07:28 / cg"
 !
 
 sum
@@ -1552,9 +1552,7 @@
      Returns 0 for an empty receiver."
 
     self isEmpty ifTrue:[^ 0].
-
-    ^ self 
-        fold:[:accum :each | accum + each].
+    ^ self fold:[:accum :each | accum + each].
 
     "
      TestCase assert: ( #() sum = 0 ).
@@ -1570,6 +1568,8 @@
                           (1 / 7).
                         } sum = (16 / 63) ).
     "
+
+    "Modified (format): / 23-10-2017 / 00:06:45 / cg"
 !
 
 sum:aBlock
@@ -4489,7 +4489,7 @@
     aStream nextPut:$)
 
     "
-     #(1 2 3 'hello' $a $ü) printOn:Transcript
+     #(1 2 3 'hello' $a $ü) printOn:Transcript
      (Array new:100000) printOn:Transcript
      (Array new:100000) printOn:Stdout
      (Array new:100000) printString size
@@ -5848,7 +5848,7 @@
 includesAll:aCollection
     "return true if the receiver includes all elements of
      the argument, aCollection; false if any is missing.
-     Notice: this method has O² runtime behavior and may be
+     Notice: this method has O² runtime behavior and may be
              slow for big receivers/args.
              Think about using a Set, or Dictionary."
 
@@ -5868,7 +5868,7 @@
      Return false if it includes none.
      Uses #= (value compare)
      Notice:
-        this method has O² runtime behavior for some subclasses and may be slow for big receivers/args.
+        this method has O² runtime behavior for some subclasses and may be slow for big receivers/args.
         Think about using a Set or Dictionary.
         Some speedup is also possible, by arranging highly
         probable elements towards the beginning of aCollection, to avoid useless searches.
@@ -5945,7 +5945,7 @@
      Return false if it includes none.
      Use identity compare for comparing.
      Notice:
-        this method has O² runtime behavior for some subclasses and may be slow for big receivers/args.
+        this method has O² runtime behavior for some subclasses and may be slow for big receivers/args.
         Think about using a Set or Dictionary.
         Some speedup is also possible, by arranging highly
         probable elements towards the beginning of aCollection, to avoid useless searches."