Skip to content

Commit

Permalink
Merge pull request #2920 from quantified-uncertainty/fix-isEqual-for-…
Browse files Browse the repository at this point in the history
…lists

Fixed isEqual for Squiggle Lists
  • Loading branch information
OAGr authored Jan 4, 2024
2 parents 9bcd0e3 + 7c4f9a3 commit 3a1c31d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/new-ways-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@quri/squiggle-lang": patch
---

Fix isEqual for Squiggle Lists
3 changes: 3 additions & 0 deletions packages/squiggle-lang/__tests__/library/builtin_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ describe("Operators", () => {
testEvalToBe("0 == true", "false");
testEvalToBe("0 == false", "false");
testEvalToBe('"" == false', "false");
testEvalToBe("[1,2,3,5] == [1,2,3,5]", "true");
testEvalToBe("[1,2,3] == [1,2,3,5]", "false");
testEvalToBe("[1,2,3,8] == [1,2,3,5]", "false", true);
testEvalToBe("normal(5,2) == normal(5,2)", "false");
testEvalToBe("Sym.normal(5,2) == Sym.normal(5,2)", "true");
testEvalToBe("Sym.uniform(10,12) == Sym.normal(5,2)", "false");
Expand Down
5 changes: 4 additions & 1 deletion packages/squiggle-lang/src/value/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ class VArray extends BaseValue implements Indexable {
}

for (let i = 0; i < this.value.length; i++) {
isEqual(this.value[i], other.value[i]);
const _isEqual = isEqual(this.value[i], other.value[i]);
if (!_isEqual) {
return false;
}
}
return true;
}
Expand Down

3 comments on commit 3a1c31d

@vercel
Copy link

@vercel vercel bot commented on 3a1c31d Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 3a1c31d Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 3a1c31d Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.