mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
update more List.walk uses
This commit is contained in:
parent
ebcee4021c
commit
15a2ac7410
3 changed files with 8 additions and 8 deletions
|
@ -25,7 +25,7 @@ initialModel = \start ->
|
||||||
cheapestOpen : (position -> F64), Model position -> Result position [ KeyNotFound ]*
|
cheapestOpen : (position -> F64), Model position -> Result position [ KeyNotFound ]*
|
||||||
cheapestOpen = \costFunction, model ->
|
cheapestOpen = \costFunction, model ->
|
||||||
|
|
||||||
folder = \position, resSmallestSoFar ->
|
folder = \resSmallestSoFar, position ->
|
||||||
when Map.get model.costs position is
|
when Map.get model.costs position is
|
||||||
Err e ->
|
Err e ->
|
||||||
Err e
|
Err e
|
||||||
|
@ -42,7 +42,7 @@ cheapestOpen = \costFunction, model ->
|
||||||
else
|
else
|
||||||
Ok smallestSoFar
|
Ok smallestSoFar
|
||||||
|
|
||||||
Set.walk model.openSet folder (Err KeyNotFound)
|
Set.walk model.openSet (Err KeyNotFound) folder
|
||||||
|> Result.map (\x -> x.position)
|
|> Result.map (\x -> x.position)
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ astar = \costFn, moveFn, goal, model ->
|
||||||
|
|
||||||
modelWithNeighbours = { modelPopped & openSet : Set.union modelPopped.openSet newNeighbours }
|
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
|
astar costFn moveFn goal modelWithCosts
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ initialModel = \start ->
|
||||||
cheapestOpen : (position -> F64), Model position -> Result position [ KeyNotFound ]*
|
cheapestOpen : (position -> F64), Model position -> Result position [ KeyNotFound ]*
|
||||||
cheapestOpen = \costFunction, model ->
|
cheapestOpen = \costFunction, model ->
|
||||||
|
|
||||||
folder = \position, resSmallestSoFar ->
|
folder = \resSmallestSoFar, position ->
|
||||||
when Dict.get model.costs position is
|
when Dict.get model.costs position is
|
||||||
Err e ->
|
Err e ->
|
||||||
Err e
|
Err e
|
||||||
|
@ -42,7 +42,7 @@ cheapestOpen = \costFunction, model ->
|
||||||
else
|
else
|
||||||
Ok smallestSoFar
|
Ok smallestSoFar
|
||||||
|
|
||||||
Set.walk model.openSet folder (Err KeyNotFound)
|
Set.walk model.openSet (Err KeyNotFound) folder
|
||||||
|> Result.map (\x -> x.position)
|
|> Result.map (\x -> x.position)
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ astar = \costFn, moveFn, goal, model ->
|
||||||
|
|
||||||
modelWithNeighbours = { modelPopped & openSet : Set.union modelPopped.openSet newNeighbours }
|
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
|
astar costFn moveFn goal modelWithCosts
|
||||||
|
|
||||||
|
|
|
@ -3396,7 +3396,7 @@ mod solve_expr {
|
||||||
cheapestOpen : Model position -> Result position [ KeyNotFound ]*
|
cheapestOpen : Model position -> Result position [ KeyNotFound ]*
|
||||||
cheapestOpen = \model ->
|
cheapestOpen = \model ->
|
||||||
|
|
||||||
folder = \position, resSmallestSoFar ->
|
folder = \resSmallestSoFar, position ->
|
||||||
when resSmallestSoFar is
|
when resSmallestSoFar is
|
||||||
Err _ -> resSmallestSoFar
|
Err _ -> resSmallestSoFar
|
||||||
Ok smallestSoFar ->
|
Ok smallestSoFar ->
|
||||||
|
@ -3689,7 +3689,7 @@ mod solve_expr {
|
||||||
List.walkBackwards
|
List.walkBackwards
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
"List a, b, (a, b -> b) -> b",
|
"List a, b, (b, a -> b) -> b",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue