You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support for index of element in a list in .traverse method #14
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
feat(list): hand element index to traverse
StevenLangbroek commentedon Feb 11, 2019
@Vikasg7 I've started implementing. As you can see the actual code change is minimal.
Vikasg7 commentedon Feb 11, 2019
@StevenLangbroek Thanks, I used RXJS instead of Task.
StevenLangbroek commentedon Feb 12, 2019
@DrBoolean do you still want this change?