Is there a standard Haskell function to the effect of
zip [0..]
or
zip [1..]
?
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> writes:To rephrase the question, is there a standard name for a function like
Is there a standard Haskell function to the effect of
zip [0..]
or
zip [1..]
?
I don't know what either that short-hand, nor the wording used in the
subject ("zip a list with sequential numbers") is supposed to mean.
If you are fining it hard to specify what you mean, either explain it by using some other programming language, or at least give a few examples[a] -> [(Int, a)]
of what you want. If zip [0..] should work, what do you want zip [0..]
to be?
[a] -> [(Int, a)]
To rephrase the question, is there a standard name for a function like
"nmb" below:
nmb :: [a] -> [(Int, a)]
nmb = zip [1..]
To rephrase the question, is there a standard name for a function like
"nmb" below:
nmb :: [a] -> [(Int, a)]
nmb = zip [1..]
and/or like "nmb0" below:
nmb0 :: [a] -> [(Int, a)]
nmb0 = zip [0..]
What should it be named? In Scala, nmb0 is zipWithIndex - but that's
already longer than the Haskell implementation...
Patrick Roemer <sangamon@netcologne.de> writes:Thanks!
What should it be named? In Scala, nmb0 is zipWithIndex - but that's
already longer than the Haskell implementation...
In Python it's "enumerate", but in Haskell I don't think a special
purpose function is needed. "zip [0..]" works perfectly well.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 307 |
Nodes: | 16 (2 / 14) |
Uptime: | 36:30:39 |
Calls: | 6,910 |
Calls today: | 4 |
Files: | 12,376 |
Messages: | 5,428,699 |
Posted today: | 2 |