lean-ja / lean-ja/lean-by-example
List.foldr の使用例: 2進数を10進数に変換する処理
Open
Nobody has claimed this yet.
コード例
- Dominant language
- Lean
- Stars
- 188
- Forks
- 15
- Avg merge
- 9h 8m
- Merged PRs (30d)
- 6
Description
/-- 2進数を10進数に変換する -/
def bin2int (bs : List Bit) : Nat :=
bs.foldr (fun a b => a + 2 * b) 0
#guard bin2int [1, 0, 1, 1] = 13
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
No target file or test is named. Search the repository for existing List.foldr examples or the relevant list-example page, then place the shown bin2int snippet with the surrounding examples and verify that its #guard check passes.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100