From 8dcaa029950a75d30329dfd61eeb734078ee3616 Mon Sep 17 00:00:00 2001 From: Erik Demaine Date: Sat, 13 Aug 2022 11:17:54 -0400 Subject: [PATCH] Remove no-longer-needed function wrappers in examples --- examples/chess/map.coffee | 2 +- examples/chess/map.js | 4 ++-- examples/polyomino/Makefile | 1 + examples/polyomino/outlines.cjsx | 22 +++++++++++++--------- examples/polyomino/outlines.coffee | 10 +++++----- examples/polyomino/outlines.jsx | 10 +++++----- examples/tetris/Makefile | 3 ++- 7 files changed, 29 insertions(+), 23 deletions(-) diff --git a/examples/chess/map.coffee b/examples/chess/map.coffee index 305a256..8432e26 100644 --- a/examples/chess/map.coffee +++ b/examples/chess/map.coffee @@ -7,7 +7,7 @@ read = (filename) -> console.assert dom.type == 'svg' dom.props.children -(key) -> -> +(key) -> # Map blanks to empty string key = key.trim() key = '' if key == '.' diff --git a/examples/chess/map.js b/examples/chess/map.js index d4c832c..c79a15a 100644 --- a/examples/chess/map.js +++ b/examples/chess/map.js @@ -8,7 +8,7 @@ function read(filename) { return dom.props.children; } -(key) => function() { +(key, context) => { // Map blanks to empty string key = key.trim(); if (key === '.') key = ''; @@ -16,7 +16,7 @@ function read(filename) { return ( - {(this.i + this.j) % 2 === 0 ? light : dark} + {(context.i + context.j) % 2 === 0 ? light : dark} {key.trim() && key !== '.' && read(`./Chess_${piece}${piece === key ? "d" : "l"}t45.svg`) } diff --git a/examples/polyomino/Makefile b/examples/polyomino/Makefile index 6807638..fef7fdd 100644 --- a/examples/polyomino/Makefile +++ b/examples/polyomino/Makefile @@ -1,3 +1,4 @@ +all: cjsx jsx coffee cjsx: svgtiler -f outlines.cjsx *.asc jsx: diff --git a/examples/polyomino/outlines.cjsx b/examples/polyomino/outlines.cjsx index fc245a8..7b93c51 100644 --- a/examples/polyomino/outlines.cjsx +++ b/examples/polyomino/outlines.cjsx @@ -1,14 +1,18 @@ Border = (props) -> -(key) -> -> +(key) -> - {if this.neighbor(-1,0).key != key - } - {if this.neighbor(+1,0).key != key - } - {if this.neighbor(0,-1).key != key - } - {if this.neighbor(0,+1).key != key - } + {if @neighbor(-1,0).key != key + + } + {if @neighbor(+1,0).key != key + + } + {if @neighbor(0,-1).key != key + + } + {if @neighbor(0,+1).key != key + + } diff --git a/examples/polyomino/outlines.coffee b/examples/polyomino/outlines.coffee index cc28e86..2ffc715 100644 --- a/examples/polyomino/outlines.coffee +++ b/examples/polyomino/outlines.coffee @@ -1,15 +1,15 @@ borderStyle = 'stroke="black" stroke-width="5" stroke-linecap="round"' -(key) -> -> +(key) -> s = ''' ''' - if this.neighbor(-1,0).key != key + if @neighbor(-1,0).key != key s += """""" - if this.neighbor(+1,0).key != key + if @neighbor(+1,0).key != key s += """""" - if this.neighbor(0,-1).key != key + if @neighbor(0,-1).key != key s += """""" - if this.neighbor(0,+1).key != key + if @neighbor(0,+1).key != key s += """""" s += '' diff --git a/examples/polyomino/outlines.jsx b/examples/polyomino/outlines.jsx index cc507ed..9254c62 100644 --- a/examples/polyomino/outlines.jsx +++ b/examples/polyomino/outlines.jsx @@ -1,15 +1,15 @@ const Border = (props) => ; -(key) => function() { +(key, context) => { return - {this.neighbor(-1,0).key !== key && + {context.neighbor(-1,0).key !== key && } - {this.neighbor(+1,0).key !== key && + {context.neighbor(+1,0).key !== key && } - {this.neighbor(0,-1).key !== key && + {context.neighbor(0,-1).key !== key && } - {this.neighbor(0,+1).key !== key && + {context.neighbor(0,+1).key !== key && } } diff --git a/examples/tetris/Makefile b/examples/tetris/Makefile index 3ee201a..a58ad48 100644 --- a/examples/tetris/Makefile +++ b/examples/tetris/Makefile @@ -1,4 +1,5 @@ -all: +all: txt coffee +txt: svgtiler -f -P NES_level7.txt example.asc coffee: svgtiler -f -P NES_level7.coffee example.asc