lean-ja / lean-ja/lean-by-example

List.foldr の使用例: 2進数を10進数に変換する処理

Open
#1,535 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.