Skip to content

Commit cea46df

Browse files
committed
Migrate shape environment to use Utils.Tree_map
Summary by Claude: Added map and mapi functions to Tree_map module in datatypes.ml Updated type definitions in row.ml (lines 234-242): dim_env and row_env now use Utils.Tree_map.t Helper functions find_dim, add_dim, find_row, add_row already existed Replaced all Map operations: Map.empty → Utils.Tree_map.empty Map.add_exn / Map.set → add_dim / add_row Map.map → Utils.Tree_map.map Map.mapi → Utils.Tree_map.mapi Map.mem → Utils.Tree_map.mem Map.find_exn → find_dim / find_row Map.update → find + add pattern
1 parent 018e7d2 commit cea46df

File tree

4 files changed

+104
-88
lines changed

4 files changed

+104
-88
lines changed

arrayjit/lib/datatypes.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,18 @@ module Tree_map = struct
218218
f ~key:n.key ~data:n.value;
219219
iter n.right ~f
220220

221+
let rec map t ~f =
222+
match t with
223+
| Empty -> Empty
224+
| Node n ->
225+
create n.key (f n.value) (map n.left ~f) (map n.right ~f)
226+
227+
let rec mapi t ~f =
228+
match t with
229+
| Empty -> Empty
230+
| Node n ->
231+
create n.key (f ~key:n.key ~data:n.value) (mapi n.left ~f) (mapi n.right ~f)
232+
221233
let to_alist t = List.rev (fold t ~init:[] ~f:(fun ~key ~data acc -> (key, data) :: acc))
222234

223235
let of_alist ~compare lst =

0 commit comments

Comments
 (0)