changeset 59:d087d0b28039

added getter with a default.
author William Morgan <billjunk@mrgn.org>
date Sun, 27 Jul 2014 21:36:51 -0700
parents 476cd9eba2be
children 863034106e02
files code/grid.lm
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/code/grid.lm	Sun Jul 27 16:52:36 2014 -0700
+++ b/code/grid.lm	Sun Jul 27 21:36:51 2014 -0700
@@ -51,6 +51,14 @@
 		((x >= 0) + (y >= 0) + (x < maxX) + (y < maxY)) > 0
 	}
 
+	grid:get:withDefault <- :grid pos default {
+		if: (grid: grid inbounds?: pos) {
+			grid: grid get: pos
+		} else: {
+			default
+		}
+	}
+
 	calcPos <- :move from {
 		x <- from value
 		y <- from tail