@@ -50,7 +50,10 @@ export default function interpret(
5050 const fn : Value = interpretHere ( expression . left ) ;
5151 if ( typeof fn != "string" && typeof fn != "number" ) {
5252 const values : Record < identifier , Variable > = { } ;
53- if ( fn . inputs . length != expression . inputs . length ) throw new Error ( "number of inputs to function call does not match number in declaration" )
53+ if ( fn . inputs . length != expression . inputs . length )
54+ throw new Error (
55+ "number of inputs to function call does not match number in declaration"
56+ ) ;
5457 for ( let [ index , identifier ] of Object . entries ( fn . inputs ) ) {
5558 values [ identifier ] = {
5659 value : interpretHere ( expression . inputs [ Number ( index ) ] ) ,
@@ -180,6 +183,11 @@ export default function interpret(
180183 const right = interpretHere ( expression . right ) ;
181184 return left === right ? 1 : 0 ;
182185 }
186+ case "!=" : {
187+ const left = interpretHere ( expression . left ) ;
188+ const right = interpretHere ( expression . right ) ;
189+ return left !== right ? 1 : 0 ;
190+ }
183191 case "&&" : {
184192 const left = interpretHere ( expression . left ) ;
185193 const right = interpretHere ( expression . right ) ;
@@ -273,9 +281,10 @@ export default function interpret(
273281 return Math . random ( ) ;
274282 case "input" :
275283 const input = prompt ( "input:" ) ?? "" ;
276- const float = parseFloat ( input ) ;
277- if ( isNaN ( float ) ) throw new Error ( "Input is not a number" ) ;
278- return float ;
284+
285+ if ( / ^ [ + - ] ? [ 0 - 9 ] + ( \. [ 0 - 9 ] + ) ? $ / . test ( input ) ) return parseFloat ( input ) ;
286+
287+ return input ;
279288 default :
280289 throw new Error ( "Unknown Macro: " + expression . identifier ) ;
281290 }
0 commit comments