-
Notifications
You must be signed in to change notification settings - Fork 14
/
Coupling.elm
44 lines (37 loc) · 989 Bytes
/
Coupling.elm
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module Challenge.Coupling exposing (coupling)
import Challenge exposing (Challenge)
import Fuzz
import Test exposing (Test)
coupling : Challenge (List Int)
coupling =
{ label = "coupling"
, fuzzer =
Fuzz.list (Fuzz.intRange 0 10)
|> Fuzz.filter
(\l ->
let
length =
List.length l
in
List.all (\i -> i < length) l
)
, test =
\list ->
list
|> List.indexedMap
(\i x ->
if i /= x then
getAt x list /= Just i
else
True
)
|> List.all identity
}
getAt : Int -> List a -> Maybe a
getAt index list =
if index < 0 then
Nothing
else
list
|> List.drop index
|> List.head