f# - Why does Array2D not have a fold operation? -


i bumped case useful have fold/foldi methods on array2d , wondered, if there reason, why array2d not have them.

as array2d quite huge, not want transform first other format.

is rare use case or there technical reasons, why methods not added? or there way achieve same without touching data in array (as in move it)?

i think having function in standard array2d module quite useful. can open issue the visual f# repository , add :-).

in addition @scrwtp wrote, can use more direct mutable implementation. basic functions this, think using mutation fine , going bit faster:

let foldi (folder: int -> int -> 's -> 't -> 's) (state: 's) (array: 't[,]) =     let mutable state = state     x in 0 .. array2d.length1 array - 1         y in 0 .. array2d.length2 array - 1             state <- folder x y state (array.[x, y])     state 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -