# HG changeset patch # User William Morgan # Date 1406355569 25200 # Node ID 4f7a421e77c60683c1d82592919bfad39dd83e4c # Parent ec0b74f4f2d959ff15e5d1d376d8d1a815c59daf Tag teaming the continuation function diff -r ec0b74f4f2d9 -r 4f7a421e77c6 code/dotScanner.lm --- a/code/dotScanner.lm Fri Jul 25 22:52:52 2014 -0700 +++ b/code/dotScanner.lm Fri Jul 25 23:19:29 2014 -0700 @@ -165,6 +165,12 @@ tree:set:to <- :tree :idx :val { tree: tree update: idx with: :el { val } } + + grid:get <- :grid :pos { + x <- pos value + y <- pos tail + get: x fromTree: (get: y fromTree: grid) + } grid:update:with <- :grid :pos :fun { x <- pos value @@ -175,7 +181,15 @@ } grid:set:to <- :grid :pos :val { - grid: grid update: pox with: :el { val } + grid: grid update: pos with: :el { val } + } + + grid:inBounds? <- :grid :pos { + x <- pos value + y <- pos tail + maxY <- grid value + maxX <- (get: 0 fromTree: grid) value + ((x >= 0) + (y >= 0) + (x < maxX) + (y < maxY)) > 0 } /* @@ -198,9 +212,8 @@ } */ - grid <- tree: ... - visited <- tree: ... - + visited <- 0 + /* advancer <- :listOfTupsLams { notdone <- 1 while: { notdone } do: { @@ -225,10 +238,53 @@ } } - //splitter: target start + } + */ + + calcPos <- :move from { + x <- from value + y <- from tail + if: move { + if: move = 1 { + x <- x + 1 + } else: { + if: move = 2 { + y <- y + 1 + } else: { + x <- x - 1 + } + } + } else: { + y <- y - 1 + } + #[x y] } - splitter <- :target start{ - + + makeContClos <- :grid myLoc path { + { + ret <- [] + move <- 0 + atpos <- 0 + if: (grid: grid inBounds?: myLoc) { + if: (grid: visited get: myLoc) { + } else: { + atpos <- grid: grid get: myLoc + if: (atpos = 2) + (atpos = 3) + (atpos = 4) { + ret <- #[1 (reverse: path)] + } else: { + visited <- grid: visited set: myLoc to: 1 + if: atpos { + move <- 0 + while: { move < 4 } do: { + ret <- (makeContClos: grid (calcPos: move myLoc) move | path) | ret + } + ret <- #[0 ret] + } else: {} + } + } + } else: {} + ret + } } //scanFor <- :target visited { @@ -241,7 +297,11 @@ visited <- treeMap: grid :el { 0 } - visited <- tree: visited set: myLoc to: 1 + /* + cont <- { + if: (grid: grid get: myLoc + visited <- tree: visited set: myLoc to: 1 + */