Talk:Data.Semigroup

From HaskellWiki
Revision as of 08:04, 15 January 2020 by Hyiltiz (talk | contribs) (a counting error?)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The page says `stimes` applies the binary operation `x` times, while in fact, the binary operation is applied `x-1` times to `x` elements in total. In the example `3 * 3 * 3 * 3`, `*` is applied three times (not four), to four elements. Here is what the page currently (Jan, 2020) says:

stimes :: Integral b => b -> a -> a
Given a number x and a value of type a, apply <> to the value x times.
stimes 4 (Product 3) -- with the type "Product a" "<>" becomes "*"
-- returns: Product {getProduct = 81} 
-- This is because (3 <> 3 <> 3 <> 3) == (3 * 3 * 3 * 3) == 81
-- i.e. 3 multiplied by itself 4 times.