Skip to content

Support for index of element in a list in .traverse method #14

Closed

Description

@Vikasg7

Hello @DrBoolean,
I am a new-comer to FP and have watched all your videos to be able to start using it.
So currently we don't have access to index of element in List().traverse() method. Can you add it?

Basically, from
List([1,2]).traverse(Task.of, (ele) => Task.of(ele))
to
List([1,2]).traverse(Task.of, (ele, index) => Task.of(ele))

workaround for now (but it may not be ideal for each situation):
List([1,2]).toMap().traverse(Task.of, (ele, index) => Task.of(ele))
So index becomes the key if we use toMap()

Also, you can take a look at other methods to make sure we have access to the index, if possible.

I hope it is something that is easy for you to implement.

Activity

  1. added a commit that references this issue on Feb 10, 2019
    4e04aa1
  2. StevenLangbroek commented on Feb 11, 2019

    @StevenLangbroek

    @Vikasg7 I've started implementing. As you can see the actual code change is minimal.

  3. Vikasg7 commented on Feb 11, 2019

    @Vikasg7
    Author

    @StevenLangbroek Thanks, I used RXJS instead of Task.

  4. StevenLangbroek commented on Feb 12, 2019

    @StevenLangbroek

    @DrBoolean do you still want this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions