Safe Haskell | None |
---|---|

Language | Haskell2010 |

# Documentation

replicateN :: (Monad m, Num n, Ord n, AsEmpty t, Cons t t a a) => (n -> m (n, a)) -> n -> m t Source

Replicate, potentially changing the remaining amount of replication.

`>>>`

[["abc","abc","abc"]]`let replicateN' :: (Int -> [(Int, String)]) -> Int -> [[String]]; replicateN' = replicateN in replicateN' (\n -> [(n, "abc")]) 3`

`>>>`

[["abc","abc","abc"],["abc","abc","def"],["abc","def"],["def","abc"],["def","def"]]`let replicateN' :: (Int -> [(Int, String)]) -> Int -> [[String]]; replicateN' = replicateN in replicateN' (\n -> [(n, "abc"), (n-1, "def")]) 3`

replicateO :: (Monad m, Num n, Ord n, AsEmpty t, Cons t t a a) => (n -> m a) -> n -> m t Source

Replicate with access to the current replication number.

`>>>`

[["3","2","1"]]`let replicateO' :: (Int -> [String]) -> Int -> [[String]]; replicateO' = replicateO in replicateO' (\n -> [show n]) 3`

`>>>`

[["3","2","1"],["3","2","0"],["3","1","1"],["3","1","0"],["2","2","1"],["2","2","0"],["2","1","1"],["2","1","0"]]`let replicateO' :: (Int -> [String]) -> Int -> [[String]]; replicateO' = replicateO in replicateO' (\n -> [show n, show (n-1)]) 3`