fix bug in not properly updating squares vector

This commit is contained in:
2025-07-06 15:52:10 +01:00
parent 270481a0ba
commit bba293d406
4 changed files with 30 additions and 9 deletions

View File

@@ -2,6 +2,24 @@ structure AppWith =
struct
open AppType
fun toList vec = Vector.foldr (fn (el, acc) => el :: acc) [] vec
fun squaresToString squares =
let
val vec =
Vector.map (fn vec =>
let
val vec = Vector.map (fn num => Int.toString num) vec
val vec: string list = toList vec
in
String.concat vec
end
) squares
val vec = toList vec
in
String.concatWith "\n" vec
end
fun addSquare (app, newX, newY, arrowX, arrowY) : app_type =
let
val
@@ -28,6 +46,7 @@ struct
, modalNum
} = app
val () = print "adding new square\n"
val squares =
Vector.mapi
(fn (idx, el) =>
@@ -35,6 +54,9 @@ struct
Vector.mapi (fn (iidx, iel) => if iidx = newY then 1 else iel) el
else
el) squares
val msg = squaresToString squares
val () = print (msg ^ "\n")
in
{ mode = mode
, squares = squares