4 ms·
You can also use: zipWith someOtherFunction [0..] listOfValues # , since someOtherFunction is likely to be # :: (Int -> Value -> Stuff) rather than # :
by a1369209993 7y ago
You can also use:
zipWith someOtherFunction [0..] listOfValues
# , since someOtherFunction is likely to be
# :: (Int -> Value -> Stuff) rather than
# :: ((Int,Value) -> Stuff) .
zipIndex f = zipWith f [0..]
# is also often useful.
- eru 7y agoYes. I wanted to keep things simpler for people who don't speak Haskell; and show off composition of simpler combinators to build more exciting things at the same time. In eg OCaml you have to use something like zipIndex (but implemented differently) or mapWithIndex, because they don't do lazy data structures by default. (And in eg Python their lazy sequences come with lots of caveats because they are not referentially transparent.)