summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/map-editor/src/Util/List.elm')
-rw-r--r-- | src/map-editor/src/Util/List.elm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/map-editor/src/Util/List.elm b/src/map-editor/src/Util/List.elm index 2bc5217..1f914b1 100644 --- a/src/map-editor/src/Util/List.elm +++ b/src/map-editor/src/Util/List.elm @@ -14,3 +14,23 @@ pop l = get_first : (a -> Bool) -> (List a) -> (Maybe a) get_first fun list = (List.head (List.filter fun list)) + +product_map : (a -> b -> c) -> (List a) -> (List b) -> (List c) +product_map product_fun list_a list_b = + (product_map_rec (product_fun) list_a list_b []) + +product_map_rec : (a -> b -> c) -> (List a) -> (List b) -> (List c) -> (List c) +product_map_rec product_fun list_a list_b result = + case (pop list_a) of + Nothing -> result + (Just (head, tail)) -> + (product_map_rec + (product_fun) + tail + list_b + (List.append + (List.map (product_fun head) list_b) + result + ) + ) + |