mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
search for multiple TRMC opportunities
This commit is contained in:
parent
b349fca521
commit
c87519c209
8 changed files with 138 additions and 116 deletions
|
@ -21,7 +21,7 @@ main =
|
|||
|> Task.putLine
|
||||
|
||||
Err GetIntError ->
|
||||
Task.putLine "Error: Failed to get Integer from stdin."
|
||||
Task.putLine "Error: Failed to get Integer from stdin."
|
||||
|
||||
Expr : [
|
||||
Add Expr Expr,
|
||||
|
|
|
@ -23,7 +23,6 @@ main =
|
|||
|
||||
Err GetIntError ->
|
||||
Task.putLine "Error: Failed to get Integer from stdin."
|
||||
|
||||
|
||||
nest : (I64, Expr -> IO Expr), I64, Expr -> IO Expr
|
||||
nest = \f, n, e -> Task.loop { s: n, f, m: n, x: e } nestHelp
|
||||
|
|
|
@ -10,8 +10,8 @@ main =
|
|||
when inputResult is
|
||||
Ok n ->
|
||||
queens n # original koka 13
|
||||
|> Num.toStr
|
||||
|> Task.putLine
|
||||
|> Num.toStr
|
||||
|> Task.putLine
|
||||
|
||||
Err GetIntError ->
|
||||
Task.putLine "Error: Failed to get Integer from stdin."
|
||||
|
@ -21,7 +21,8 @@ ConsList a : [Nil, Cons a (ConsList a)]
|
|||
queens = \n -> length (findSolutions n n)
|
||||
|
||||
findSolutions = \n, k ->
|
||||
if k <= 0 then # should we use U64 as input type here instead?
|
||||
if k <= 0 then
|
||||
# should we use U64 as input type here instead?
|
||||
Cons Nil Nil
|
||||
else
|
||||
extend n Nil (findSolutions n (k - 1))
|
||||
|
@ -40,7 +41,6 @@ appendSafe = \k, soln, solns ->
|
|||
else
|
||||
appendSafe (k - 1) soln solns
|
||||
|
||||
|
||||
safe : I64, I64, ConsList I64 -> Bool
|
||||
safe = \queen, diagonal, xs ->
|
||||
when xs is
|
||||
|
@ -51,7 +51,6 @@ safe = \queen, diagonal, xs ->
|
|||
else
|
||||
Bool.false
|
||||
|
||||
|
||||
length : ConsList a -> I64
|
||||
length = \xs ->
|
||||
lengthHelp xs 0
|
||||
|
|
|
@ -23,7 +23,6 @@ main =
|
|||
|
||||
Err GetIntError ->
|
||||
Task.putLine "Error: Failed to get Integer from stdin."
|
||||
|
||||
|
||||
sort : List I64 -> List I64
|
||||
sort = \list ->
|
||||
|
|
|
@ -93,9 +93,15 @@ ins = \tree, kx, vx ->
|
|||
|
||||
Node Black a ky vy b ->
|
||||
if lt kx ky then
|
||||
(if isRed a then balance1 (Node Black Leaf ky vy b) (ins a kx vx) else Node Black (ins a kx vx) ky vy b)
|
||||
if isRed a then
|
||||
balance1 (Node Black Leaf ky vy b) (ins a kx vx)
|
||||
else
|
||||
Node Black (ins a kx vx) ky vy b
|
||||
else if lt ky kx then
|
||||
(if isRed b then balance2 (Node Black a ky vy Leaf) (ins b kx vx) else Node Black a ky vy (ins b kx vx))
|
||||
if isRed b then
|
||||
balance2 (Node Black a ky vy Leaf) (ins b kx vx)
|
||||
else
|
||||
Node Black a ky vy (ins b kx vx)
|
||||
else
|
||||
Node Black a kx vx b
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ main =
|
|||
|
||||
Err GetIntError ->
|
||||
Task.putLine "Error: Failed to get Integer from stdin."
|
||||
|
||||
|
||||
boom : Str -> a
|
||||
boom = \_ -> boom ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue