@@ -126,6 +126,20 @@ pow' : RingWithUnity a => a -> Nat -> a
126pow' _ Z = unity
126pow' _ Z = unity
127pow' x (S n) = x <.> pow' x n
127pow' x (S n) = x <.> pow' x n
129+-- TODO: This can be more efficient:
130+-- stimes 5 x = x <+> (x <+> (x <+> (x <+> x)))
131+-- = x <+> ((x <+> x) <+> (x <+> x))
132+-- = let y = x <+> x in x <+> (y <+> y)
134+||| Combine `n` copies of a value with `<+>`
135+stimes : Semigroup a => (n : Nat) -> {auto prf : IsSucc n} -> a -> a
137+stimes (S (S k)) x = x <+> stimes (S k) x
139+||| Like `stimes`, but accepting `Z` as argument.
140+mtimes : Monoid a => (n : Nat) -> a -> a
142+mtimes (S k) x = stimes (S k) x
130-- XXX todo:
144-- XXX todo:
131-- Structures where "abs" make sense.
145-- Structures where "abs" make sense.