Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.haskell > #494 > unrolled thread
| Started by | Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> |
|---|---|
| First post | 2018-10-14 19:32 -0400 |
| Last post | 2018-10-17 01:43 -0400 |
| Articles | 8 — 4 participants |
Back to article view | Back to comp.lang.haskell
standard function to zip a list with sequential numbers Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2018-10-14 19:32 -0400
Re: standard function to zip a list with sequential numbers Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-10-15 02:55 +0100
Re: standard function to zip a list with sequential numbers Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2018-10-14 22:47 -0400
Re: standard function to zip a list with sequential numbers Paul Rubin <no.email@nospam.invalid> - 2018-10-14 20:02 -0700
Re: standard function to zip a list with sequential numbers Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-10-15 16:43 +0100
Re: standard function to zip a list with sequential numbers Patrick Roemer <sangamon@netcologne.de> - 2018-10-16 17:41 +0200
Re: standard function to zip a list with sequential numbers Paul Rubin <no.email@nospam.invalid> - 2018-10-16 10:56 -0700
Re: standard function to zip a list with sequential numbers Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2018-10-17 01:43 -0400
| From | Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> |
|---|---|
| Date | 2018-10-14 19:32 -0400 |
| Subject | standard function to zip a list with sequential numbers |
| Message-ID | <0mQwD.236894$ZJ2.33603@fx33.iad> |
Is there a standard Haskell function to the effect of zip [0..] or zip [1..] ? Thank you, -Pavel
[toc] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2018-10-15 02:55 +0100 |
| Message-ID | <87woqkkm7f.fsf@bsb.me.uk> |
| In reply to | #494 |
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> writes:
> 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
of what you want. If zip [0..] should work, what do you want zip [0..]
to be?
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> |
|---|---|
| Date | 2018-10-14 22:47 -0400 |
| Message-ID | <9dTwD.237216$SN2.12769@fx38.iad> |
| In reply to | #495 |
Ben Bacarisse wrote:
> Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> writes:
>
>> 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.
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..]
>
> 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
> of what you want. If zip [0..] should work, what do you want zip [0..]
> to be?
[a] -> [(Int, a)]
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2018-10-14 20:02 -0700 |
| Message-ID | <877eijnc80.fsf@nightsong.com> |
| In reply to | #496 |
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> writes: > [a] -> [(Int, a)] Integral n => [a] -> [(n, a)]
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2018-10-15 16:43 +0100 |
| Message-ID | <87ftx7kyft.fsf@bsb.me.uk> |
| In reply to | #496 |
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> writes: <snip> > To rephrase the question, is there a standard name for a function like > "nmb" below: > > nmb :: [a] -> [(Int, a)] > nmb = zip [1..] Oh I see -- and now your earlier description makes sense! But no there isn't a standard name for zip [1..]. -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Patrick Roemer <sangamon@netcologne.de> |
|---|---|
| Date | 2018-10-16 17:41 +0200 |
| Message-ID | <pq50ru$6th$1@newsreader4.netcologne.de> |
| In reply to | #496 |
Responding to Pavel: > 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... Best regards, Patrick
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2018-10-16 10:56 -0700 |
| Message-ID | <87pnw9lqqc.fsf@nightsong.com> |
| In reply to | #501 |
Patrick Roemer <sangamon@netcologne.de> writes: > 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.
[toc] | [prev] | [next] | [standalone]
| From | Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> |
|---|---|
| Date | 2018-10-17 01:43 -0400 |
| Message-ID | <TZzxD.479668$4S3.207827@fx47.iad> |
| In reply to | #503 |
Paul Rubin wrote: > Patrick Roemer <sangamon@netcologne.de> writes: >> 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. Thanks! I don't like how it pollutes the code when I need to use it many times in one function; also composition with other functions is even cleaner if it's one word, even if it's long (for readability, 1 token vs 5 means makes lots of difference). But it's ok -- just did not want to pollute peoples' brains with a new name for a thing that might have already had a name. I thought of enum[erate] but it seems to be used for different things in Haskell. Somehow never thought of borrowing from Scala -- thanks Patrick for the idea. zipWith0BasedIndex, zipWith1BasedIndex it is now -- haters are welcomed (just kidding). -Pavel
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.haskell
csiph-web