On Friday, November 17, 2017 at 8:25:22 AM UTC, Francisco Ramos wrote: > > Hi there, > > Was wondering how I can map over an array with a start and end indexes. I > know I could slice the array and then map, but performance is a concern and > slicing is O(N) where N = end - start, plus the actual mapping, another > O(N). > > Maybe there is another way where I just loop once over the array? >
You could write your own using Array.get. But I can see that will be a PITA, as it returns a Maybe, so you might also end up having to supply a default value for the case where get gives you a Nothing, but in practice that default will never be used. Or have your custom map function also return a Maybe, and output Nothing if the indexes are out of bounds and Array.get returns Nothing? -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
