Skip to content

Commit

Permalink
Merge pull request #107 from JohanWiltink/main
Browse files Browse the repository at this point in the history
allow for nullish JS values as expressions
  • Loading branch information
JohanWiltink authored Feb 1, 2024
2 parents b89b755 + 79dd1d9 commit 9fcb1c3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lambda-calculus.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class L {
this.body = body;
}
free() {
const r = this.body.free?.() || new Set ;
const r = this.body?.free?.() || new Set ;
r.delete(this.name);
return r;
}
Expand All @@ -58,7 +58,7 @@ class A {
this.left = left;
this.right = right;
}
free() { return union( this.left.free?.() || [] , this.right.free?.() || [] ); }
free() { return union( this.left?.free?.() || [] , this.right?.free?.() || [] ); }
toString() {
const left = this.left instanceof L ? `(${this.left})` : this.left ;
const right = this.right instanceof V ? this.right : `(${this.right})` ;
Expand Down Expand Up @@ -169,7 +169,7 @@ export function toInt(term) {
function parse(code) {
function parseTerm(env,code) {
function wrap(name,term) {
const FV = term.free?.() || new Set ; FV.delete("()");
const FV = term?.free?.() || new Set ; FV.delete("()");
if ( config.purity === "Let" )
return Array.from(FV).reduce( (tm,nm) => {
if ( env.has(nm) ) {
Expand Down

0 comments on commit 9fcb1c3

Please sign in to comment.