mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-08-16 19:40:22 +03:00
Use a let expression
This commit is contained in:
parent
75650d1952
commit
776cb6f293
@ -469,29 +469,33 @@ reportError knownClasses range name =
|
|||||||
|
|
||||||
similarClasses : String -> Set String -> List String
|
similarClasses : String -> Set String -> List String
|
||||||
similarClasses targetClass knownClasses =
|
similarClasses targetClass knownClasses =
|
||||||
Set.foldl
|
let
|
||||||
(\class ({ first, second } as untouched) ->
|
classes : { first : Maybe { class : String, distance : Int }, second : Maybe { class : String, distance : Int } }
|
||||||
let
|
classes =
|
||||||
distance : Int
|
Set.foldl
|
||||||
distance =
|
(\class ({ first, second } as untouched) ->
|
||||||
computeDistance class targetClass
|
let
|
||||||
in
|
distance : Int
|
||||||
if isSmallerDistance distance first then
|
distance =
|
||||||
{ first = Just { class = class, distance = distance }
|
computeDistance class targetClass
|
||||||
, second = first
|
in
|
||||||
}
|
if isSmallerDistance distance first then
|
||||||
|
{ first = Just { class = class, distance = distance }
|
||||||
|
, second = first
|
||||||
|
}
|
||||||
|
|
||||||
else if isSmallerDistance distance second then
|
else if isSmallerDistance distance second then
|
||||||
{ first = first
|
{ first = first
|
||||||
, second = Just { class = class, distance = distance }
|
, second = Just { class = class, distance = distance }
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
untouched
|
untouched
|
||||||
)
|
)
|
||||||
{ first = Nothing, second = Nothing }
|
{ first = Nothing, second = Nothing }
|
||||||
knownClasses
|
knownClasses
|
||||||
|> (\{ first, second } -> List.filterMap (Maybe.map .class) [ first, second ])
|
in
|
||||||
|
List.filterMap (Maybe.map .class) [ classes.first, classes.second ]
|
||||||
|
|
||||||
|
|
||||||
isSmallerDistance : Int -> Maybe { a | distance : Int } -> Bool
|
isSmallerDistance : Int -> Maybe { a | distance : Int } -> Bool
|
||||||
|
Loading…
Reference in New Issue
Block a user