Module Ptree.Payload
Maps and folds at any payload: a mask, a learning rate per array, a plan, dimensions. The positions of the parameter hold the payloads; fixed arrays, and those of parts walked with Walk.structure, are kept from the first value, and neither passed nor compared.
map (module U) f x is x with each payload a at path p replaced by f p a, in walk order.
val map2 :
(module U : S)
->
(Path.t -> 'a -> 'b -> 'c) ->
('a, 'd) U.t ->
('b, 'd) U.t ->
('c, 'd) U.tmap2 (module U) f x y is x with each payload a at path p replaced by f p a b, b y's payload at p.
Raises Invalid_argument before applying f if x and y differ in their payloads' paths or in their reports, with the message of Maps and folds prefixed by "Nx.Ptree.Payload.map2", and if U.walk walks one value two ways.
fold (module U) f x acc is f pn an (… (f p1 a1 acc)), a1, …, an x's payloads and p1, …, pn their paths, in walk order. f takes the accumulator last, as Ptree.fold's does. x's payloads in walk order are List.rev (fold (module U) (fun _ a l -> a :: l) x []).