From c714bf672180c7ba627aa8036c139366eda46607 Mon Sep 17 00:00:00 2001 From: Arjo Bruijnes Date: Fri, 29 Dec 2023 00:59:03 +0100 Subject: [PATCH] Allow type transformations with mapper for Map Matching the return type of the mapper function with the return types of the given map functions F and G, allows the mapper function to be used to transform key and value types. Previous definition only works for map functions that return the same type as they are given. --- src/org/rascalmpl/library/Map.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/rascalmpl/library/Map.rsc b/src/org/rascalmpl/library/Map.rsc index c88045522cb..4512649e89f 100644 --- a/src/org/rascalmpl/library/Map.rsc +++ b/src/org/rascalmpl/library/Map.rsc @@ -157,7 +157,7 @@ int incr(int x) { return x + 1; } mapper(("apple": 1, "pear": 2, "orange": 3), prefix, incr); ``` } -public map[&K, &V] mapper(map[&K, &V] M, &L (&K) F, &W (&V) G) +public map[&L, &W] mapper(map[&K, &V] M, &L (&K) F, &W (&V) G) = (F(key) : G(M[key]) | &K key <- M);