search for multiple TRMC opportunities

This commit is contained in:
Folkert 2023-06-21 20:56:36 +02:00
parent b349fca521
commit c87519c209
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
8 changed files with 138 additions and 116 deletions

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -23,7 +23,6 @@ main =
Err GetIntError ->
Task.putLine "Error: Failed to get Integer from stdin."
sort : List I64 -> List I64
sort = \list ->

View file

@ -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

View file

@ -26,7 +26,6 @@ main =
Err GetIntError ->
Task.putLine "Error: Failed to get Integer from stdin."
boom : Str -> a
boom = \_ -> boom ""