changeset 26:4f7a421e77c6

Tag teaming the continuation function
author William Morgan <billjunk@mrgn.org>
date Fri, 25 Jul 2014 23:19:29 -0700
parents ec0b74f4f2d9
children abd8ceef0dd8
files code/dotScanner.lm
diffstat 1 files changed, 68 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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
+		*/