Skip to content

Commit 9033667

Browse files
authoredJul 6, 2022
Merge pull request #96 from JohanWiltink/main
delay `fromInt` from `n` to `negative`
2 parents 57a7edf + d27c2b6 commit 9033667

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎src/lambda-calculus.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function parse(code) {
233233
if ( digits.test(code[i]) ) {
234234
let j = i+1;
235235
while ( digits.test(code[j]) ) j++;
236-
return [sp(j),fromInt(Number(code.slice(i,j)))];
236+
return [ sp(j), fromInt(Number(code.slice(i,j))), Number(code.slice(i,j)) ]; // return JS number in addition to LC number // negative uses this
237237
} else
238238
return null;
239239
}
@@ -285,8 +285,8 @@ function parse(code) {
285285
if ( j ) {
286286
const q = number(j);
287287
if ( q ) {
288-
const [k,r] = q;
289-
return [k,fromInt(-toInt(r))];
288+
const [k,,r] = q; // act on the JS number instead of the LC number
289+
return [k,fromInt(-r)];
290290
} else
291291
error(j,"negative: expected a number literal")
292292
} else

0 commit comments

Comments
 (0)
Please sign in to comment.