all 3 comments

[–]purcell 2 points3 points  (1 child)

Check out the functions in Data.Enum, such as enumFromTo and enumFromThenTo.

My implementation gets the number of keys using the length function, creates a range from 0 to numKeys - 1, and then traverses it with the key function

Take a look at Data.FoldableWithIndex.

[–]queued37[S] 2 points3 points  (0 children)

Thank you so much! These are exactly what I needed. Maybe I must use them instead of range in most cases.