blob: 69d329c109db8b1f43a902a25624d8ea56051b56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
module Util.Array exposing (update, update_unsafe)
import Array
update : (
Int ->
((Maybe t) -> (Maybe t)) ->
(Array.Array t) ->
(Array.Array t)
)
update index fun array =
case (fun (Array.get index array)) of
Nothing -> array
(Just e) -> (Array.set index e array)
update_unsafe : (
Int ->
(t -> t) ->
(Array.Array t) ->
(Array.Array t)
)
update_unsafe index fun array =
case (Array.get index array) of
Nothing -> array
(Just e) -> (Array.set index (fun e) array)
|