product -package:ListLike

The product function computes the product of the numbers of a structure.

Examples

Basic usage:
>>> product []
1
>>> product [42]
42
>>> product [1..10]
3628800
>>> product [4.1, 2.0, 1.7]
13.939999999999998
>>> product [1..]
* Hangs forever *
The product function computes the product of a finite list of numbers.
>>> product []
1

>>> product [42]
42

>>> product [1..10]
3628800

>>> product [4.1, 2.0, 1.7]
13.939999999999998

>>> product [1..]
* Hangs forever *
O(n) Compute the product of the elements.

Examples

>>> import qualified Data.Vector as V

>>> V.product $ V.fromList [1,2,3,4]
24

>>> V.product (V.empty :: V.Vector Int)
1
O(n) Compute the product of the elements.

Examples

>>> import qualified Data.Vector.Strict as V

>>> V.product $ V.fromList [1,2,3,4]
24

>>> V.product (V.empty :: V.Vector Int)
1
O(n) Compute the product of the elements.

Examples

>>> import qualified Data.Vector.Primitive as VP

>>> VP.product $ VP.fromList [1,2,3,4 :: Int]
24

>>> VP.product (VP.empty :: VP.Vector Int)
1
O(n) Compute the product of the elements.

Examples

>>> import qualified Data.Vector.Storable as VS

>>> VS.product $ VS.fromList [1,2,3,4 :: Int]
24

>>> VS.product (VS.empty :: VS.Vector Int)
1
O(n) Compute the product of the elements.

Examples

>>> import qualified Data.Vector.Unboxed as VU

>>> VU.product $ VU.fromList [1,2,3,4 :: Int]
24

>>> VU.product (VU.empty :: VU.Vector Int)
1
Get the product of all values in the stream. Subject to fusion
Compute the product of the elements of a Producer
Computes the product of all elements
Stricter version of product.
>>> product [1..10]
3628800
Fold a Stream of numbers into their product with the return value
mapped product :: Stream (Stream (Of Int)) m r -> Stream (Of Int) m r
The product function computes the product of the numbers of a structure.
O(n) Compute the produce of the elements

Examples

>>> import qualified Data.Vector as V

>>> V.product $ V.fromList [1,2,3,4 :: Int]
24

>>> V.product (V.empty :: V.Vector Int)
1
O(n) Compute the produce of the elements

Examples

>>> import qualified Data.Vector as V

>>> V.product $ V.fromList [1,2,3,4 :: Int]
24

>>> V.product (V.empty :: V.Vector Int)
1
O(n) Compute the produce of the elements

Examples

>>> import qualified Data.Vector.Storable as VS

>>> VS.product $ VS.fromList [1,2,3,4 :: Int]
24

>>> VS.product (VS.empty :: VS.Vector Int)
1
O(n) Compute the produce of the elements

Examples

>>> import qualified Data.Vector.Unboxed as VU

>>> VU.product $ VU.fromList [1,2,3,4 :: Int]
24

>>> VU.product (VU.empty :: VU.Vector Int)
1
Synonym for oproduct
product does not need a one for initialization
Determine the product of all elements of a stream of numbers. Returns 1 when the stream is empty.
product = Stream.fold Fold.product
Compute the product of a finite list of numbers.
\(Array16 xs)  ->  Array.product xs == product (Array.toList xs)