lean-ja / lean-ja/lean-by-example
Repr に登場する括弧を削除するために優先順位を考慮する例
Open
Nobody has claimed this yet.
コード例
メタプログラミング
- Dominant language
- Lean
- Stars
- 188
- Forks
- 15
- Avg merge
- 9h 8m
- Merged PRs (30d)
- 6
Description
Zulip: Control parentheses in Repr
def Formula.repr [ToString α] (fm : Formula α) (n : Nat) :=
match fm with
| .Atom s => Std.Format.text (ToString.toString s)
| .And p q => Std.Format.text s!"{Formula.repr p 60} ∧ {Formula.repr q 60}"
| .Or p q =>
if n >= 60 then
Std.Format.text s!"({Formula.repr p n} ∨ {Formula.repr q n})"
else
Std.Format.text s!"{Formula.repr p n} ∨ {Formula.repr q n}"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Formula.repr example shown in the issue and inspect where this example is stored in the repository. Check how the precedence value controls parentheses, then update the example so its intended precedence-aware behavior is clear. Done means the example demonstrates removing unnecessary parentheses while retaining them when required.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100