Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the molding functions #1162

Closed
wants to merge 2 commits into from
Closed

Fix the molding functions #1162

wants to merge 2 commits into from

Conversation

lyxal
Copy link
Member

@lyxal lyxal commented Jun 24, 2022

Goes towards closing #1119

@lyxal lyxal added PR: Bug Fix PR only tag - a PR that is fixing a bug/issue The Great Bug Fix labels Jun 24, 2022
@lyxal lyxal mentioned this pull request Jun 24, 2022
31 tasks
cgccuser
cgccuser previously approved these changes Jun 24, 2022
Copy link
Member

@cgccuser cgccuser left a comment

Choose a reason for hiding this comment

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

I'm too smol brain to understand this code but the tests for this command seem to pass so LGTM

@cgccuser cgccuser added this to the The Great Bug Fix milestone Jun 24, 2022
@cgccuser cgccuser enabled auto-merge (squash) June 24, 2022 13:53
Copy link
Contributor

@Steffan153 Steffan153 left a comment

Choose a reason for hiding this comment

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

this does not work. say, try molding [4,5,6] to [[1,[2],[]],[[3]]]

Copy link
Contributor

@Steffan153 Steffan153 left a comment

Choose a reason for hiding this comment

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

@lyxal
Copy link
Member Author

lyxal commented Jun 24, 2022

you could copy this from jelly. it's just 9 lines https://github.com/DennisMitchell/jellylanguage/blob/master/jelly/interpreter.py#L578-L586

Mutability and lazylists say otherwise.

@cgccuser
Copy link
Member

Wasn't it already copied from Jelly and then modified?

@lyxal
Copy link
Member Author

lyxal commented Jun 24, 2022

Wasn't it already copied from Jelly and then modified?

That's right. In theory, it should still be the same(ish) algorithm just better suited for LazyLists and immutability.

Goes towards closing #1119
break
temp.append(obj)
if type(_) in [list, LazyList]:
temp = mold(content[: len(_)], _)
Copy link
Member

Choose a reason for hiding this comment

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

Should this not be recursing mold_without_repeat?

@@ -653,23 +653,29 @@ def mold(
The content, molded into the shape.
"""
final = []
original, content = itertools.tee(content)
original, content = map(LazyList, itertools.tee(content))
Copy link
Member

Choose a reason for hiding this comment

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

This will only map at depth 1.

@lyxal
Copy link
Member Author

lyxal commented Jun 25, 2022

Replaced by #1167

@lyxal lyxal closed this Jun 25, 2022
@lyxal lyxal deleted the improve_mold branch June 25, 2022 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Bug Fix PR only tag - a PR that is fixing a bug/issue The Great Bug Fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants