Skip to content

Commit

Permalink
Merge pull request #1451 from Vyxal/fix-untruth
Browse files Browse the repository at this point in the history
Make untruth work on `0` and `[]`
  • Loading branch information
lyxal committed Oct 2, 2022
2 parents 333834a + e512a7b commit 02127e3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions documents/knowledge/elements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5437,6 +5437,7 @@
- "[[0,3,4,6]] : [1,0,0,1,1,0,1]"
- "[[[0,1,0],[2,0,3],[1,0,1]]] : [[[0, 0, 0, 0], [1, 0, 0, 0]], [[0, 1, 0, 0], [0, 0, 0, 0]], [[0, 0, 0, 1], [0, 0, 0, 0]]]"
- "[[]] : []"
- "[0] : [1]"

- element: "ÞǓ"
name: Connected Uniquify
Expand Down
21 changes: 21 additions & 0 deletions tests/test_elements.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion vyxal/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -5704,7 +5704,9 @@ def untruth(lhs, ctx):
ref = ref[x[i]]
ref[x[dimensions - 1]] = 1
return matrix
return [int(x in lhs) for x in range((monadic_maximum(lhs, ctx) or -1) + 1)]
if not lhs and lhs != 0:
return []
return [int(x in lhs) for x in range(monadic_maximum(lhs, ctx) + 1)]


def unwrap(lhs, ctx):
Expand Down

0 comments on commit 02127e3

Please sign in to comment.