Hi, Does using Array.indexedMap suit you?
import Array exposing (Array) submap : Int -> Int -> (a -> a) -> Array a -> Array a submap start end func = Array.indexedMap (\i -> if i >= start && i < end then func else identity) Of course the result must be of the same type in this case. On Friday, November 17, 2017 at 9:25:22 AM UTC+1, 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? > > Thanks a lot, > Fran > -- 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 elm-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.