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

FR: List.filter() #5291

Closed
msuozzo opened this issue Jan 8, 2025 · 0 comments · Fixed by #5436
Closed

FR: List.filter() #5291

msuozzo opened this issue Jan 8, 2025 · 0 comments · Fixed by #5436
Labels
enhancement New feature or request

Comments

@msuozzo
Copy link

msuozzo commented Jan 8, 2025

Is your feature request related to a problem? Please describe.

I wanted to implement "labels" in a git commit message with lines of the form "label: value". Using the current Template functionality, adding a line is easy (concat(), String.join()) but removing is trickier. An LLM generated description.lines().filter(...) which looked correct before I tried it and discovered filter() was hallucinated.

Describe the solution you'd like
List.filter() in a similar form to List.map()

Describe alternatives you've considered
@bryceberger put together a workaround using List.map() which uses the empty string for excluded lines and moves the "gather" operation (join in this case) into the map expression.

description.lines().map(|line| if(<predicate>, line ++ "\n")).join("")

Still, there are clear limitations with this approach and I wouldn't expect it to be maintainable extending beyond a few successive calls. So while it does the trick, I think there's an opportunity to add a more ergonomic alternative.

Additional context
Discord discourse: https://discord.com/channels/968932220549103686/1326247959213506682

@yuja yuja added the enhancement New feature or request label Jan 8, 2025
yuja added a commit to yuja/jj that referenced this issue Jan 23, 2025
If we add generic diff template, we'll probably want to filter diff entries by
status, etc.

Closes jj-vcs#5291
yuja added a commit to yuja/jj that referenced this issue Jan 23, 2025
If we add generic diff template, we'll probably want to filter diff entries by
status, etc.

Closes jj-vcs#5291
yuja added a commit to yuja/jj that referenced this issue Jan 23, 2025
If we add generic diff template, we'll probably want to filter diff entries by
status, etc.

Closes jj-vcs#5291
github-merge-queue bot pushed a commit that referenced this issue Jan 24, 2025
If we add generic diff template, we'll probably want to filter diff entries by
status, etc.

Closes #5291
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants