Skip to content

Commit

Permalink
Allow type transformations with mapper for Map
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
weirdwater committed Dec 28, 2023
1 parent f604f30 commit c714bf6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/org/rascalmpl/library/Map.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c714bf6

Please sign in to comment.