Mercurial > repos > icfp2014
view code/dotScanner.lm @ 24:37158acf31e5
Initial pass at scan loop
author | William Morgan <billjunk@mrgn.org> |
---|---|
date | Fri, 25 Jul 2014 22:52:05 -0700 |
parents | 1c6d4f2642d0 |
children | ec0b74f4f2d9 |
line wrap: on
line source
#{ /* ListGet <- :cell idx { if: idx = 0 {cell value} else: { ListGet: (cell tail) (idx - 1) } } TupGet <- :cell depth size { if: idx = 0 {cell value} else: { if: size = 1 {cell tail} else: { // warning, out-of-bounds idx will return a value! TupGet: (cell tail) (idx - 1) (size - 1) }} } // rowmajor lists GridGet <- :x y w h{ ListGet ... } */ grid <- tree: ... visited <- tree: ... advancer <- :listOfTupsLams { notdone <- 1 while: { notdone } do: { listOfLamTups <- fold: listOfLamTups [] with: :acc el{ ret <- 0 newTupLams <- (el tail): // zero means "I have not found it" if: (el value) = 0 { newTupLams <- (el tail): if: (isInteger?: newTupLams) { ret <- acc } else: { ret <- acc | newTupLams } } else: { notdone <- 0 ret <- [(el tail)] } } } //splitter: target start } splitter <- :target start{ } //scanFor <- :target visited { //} counterLoad <- 4 step <- :myState world { print: (world value) //myPos <- path <- [3 1 3 1] //scanFor: 2 3 [myPos] move <- myState value counter <- (myState tail) - 1 if: counter = 0 { move <- move + 1 counter <- counterLoad if: move = 4 { move <- 0 } else: {} } else: {} #[#[move counter] ((path tail) value)] } main <- :initWorld mystery { #[#[0 counterLoad] step] } } //does not work: //someListOrTup get: 0 //lambdaman program (step function) faulted TagMismatch