10
0
mirror of https://gitlab.com/scemama/EZFIO.git synced 2024-11-19 04:22:25 +01:00

Tail recursion in ocaml flatten_ezfio

This commit is contained in:
Anthony Scemama 2014-11-03 18:12:13 +01:00
parent 293c6b971a
commit aae15b024a

View File

@ -308,10 +308,10 @@ let ezfio_get_element { rank=r ; dim=d ; data=data } coord =
let flattened_ezfio { rank ; dim ; data } = let flattened_ezfio { rank ; dim ; data } =
let flatten_2 d = let flatten_2 d =
let l = List.map (function let l = List.rev_map (function
| Ezfio_item i -> i | Ezfio_item i -> i
| Ezfio_data i -> assert false | Ezfio_data i -> assert false
) (Array.to_list d) ) (List.rev (Array.to_list d))
in Array.concat l in Array.concat l
in in
@ -319,10 +319,10 @@ let flattened_ezfio { rank ; dim ; data } =
if (rank = 2) then if (rank = 2) then
flatten_2 d flatten_2 d
else else
let l = List.map (function let l = List.rev_map (function
| Ezfio_data x -> flatten_n (rank-1) x | Ezfio_data x -> flatten_n (rank-1) x
| Ezfio_item _ -> assert false | Ezfio_item _ -> assert false
) (Array.to_list d) ) (List.rev (Array.to_list d))
in Array.concat l in Array.concat l
in in