2020-10-21 22:36:51 +03:00
|
|
|
|
|
|
|
```ucm
|
2024-06-12 01:22:09 +03:00
|
|
|
scratch/main> builtins.merge
|
2020-10-21 22:36:51 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
```unison
|
|
|
|
-- List.map : (a -> b) -> [a] -> [b]
|
2020-10-22 03:57:58 +03:00
|
|
|
List.map f =
|
2020-10-21 22:36:51 +03:00
|
|
|
go acc = cases
|
|
|
|
[] -> acc
|
|
|
|
h +: t -> go (acc :+ f h) t
|
|
|
|
go []
|
|
|
|
```
|
|
|
|
|
|
|
|
```ucm
|
2024-06-12 01:22:09 +03:00
|
|
|
scratch/main> add
|
|
|
|
scratch/main> view List.map
|
2020-10-21 22:36:51 +03:00
|
|
|
```
|
2020-10-22 03:57:58 +03:00
|
|
|
|
|
|
|
```unison
|
|
|
|
List.map2 : (g -> g2) -> [g] -> [g2]
|
|
|
|
List.map2 f =
|
|
|
|
unused = "just to give this a different hash"
|
|
|
|
go acc = cases
|
|
|
|
[] -> acc
|
|
|
|
h +: t -> go (acc :+ f h) t
|
|
|
|
go []
|
|
|
|
```
|