update more List.walk uses

This commit is contained in:
Folkert 2021-10-10 12:35:52 +02:00
parent ebcee4021c
commit 15a2ac7410
3 changed files with 8 additions and 8 deletions

View file

@ -25,7 +25,7 @@ initialModel = \start ->
cheapestOpen : (position -> F64), Model position -> Result position [ KeyNotFound ]*
cheapestOpen = \costFunction, model ->
folder = \position, resSmallestSoFar ->
folder = \resSmallestSoFar, position ->
when Map.get model.costs position is
Err e ->
Err e
@ -42,7 +42,7 @@ cheapestOpen = \costFunction, model ->
else
Ok smallestSoFar
Set.walk model.openSet folder (Err KeyNotFound)
Set.walk model.openSet (Err KeyNotFound) folder
|> Result.map (\x -> x.position)
@ -105,7 +105,7 @@ astar = \costFn, moveFn, goal, model ->
modelWithNeighbours = { modelPopped & openSet : Set.union modelPopped.openSet newNeighbours }
modelWithCosts = Set.walk newNeighbours (\nb, md -> updateCost current nb md) modelWithNeighbours
modelWithCosts = Set.walk newNeighbours modelWithNeighbours (\md, nb -> updateCost current nb md)
astar costFn moveFn goal modelWithCosts

View file

@ -25,7 +25,7 @@ initialModel = \start ->
cheapestOpen : (position -> F64), Model position -> Result position [ KeyNotFound ]*
cheapestOpen = \costFunction, model ->
folder = \position, resSmallestSoFar ->
folder = \resSmallestSoFar, position ->
when Dict.get model.costs position is
Err e ->
Err e
@ -42,7 +42,7 @@ cheapestOpen = \costFunction, model ->
else
Ok smallestSoFar
Set.walk model.openSet folder (Err KeyNotFound)
Set.walk model.openSet (Err KeyNotFound) folder
|> Result.map (\x -> x.position)
@ -105,7 +105,7 @@ astar = \costFn, moveFn, goal, model ->
modelWithNeighbours = { modelPopped & openSet : Set.union modelPopped.openSet newNeighbours }
modelWithCosts = Set.walk newNeighbours (\nb, md -> updateCost current nb md) modelWithNeighbours
modelWithCosts = Set.walk newNeighbours modelWithNeighbours (\md, nb -> updateCost current nb md)
astar costFn moveFn goal modelWithCosts

View file

@ -3396,7 +3396,7 @@ mod solve_expr {
cheapestOpen : Model position -> Result position [ KeyNotFound ]*
cheapestOpen = \model ->
folder = \position, resSmallestSoFar ->
folder = \resSmallestSoFar, position ->
when resSmallestSoFar is
Err _ -> resSmallestSoFar
Ok smallestSoFar ->
@ -3689,7 +3689,7 @@ mod solve_expr {
List.walkBackwards
"#
),
"List a, b, (a, b -> b) -> b",
"List a, b, (b, a -> b) -> b",
);
}