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

List.foldl の使用例:二項演算の双方の型が同じではないケース(累積)

Open
#1,020 0 comments 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

Lean 99 の Problem 57 より

def BinTree.searchTreeFromList [Ord α] (xs : List α) : BinTree α :=
  -- sorry
  xs.foldl insert BinTree.empty
where
  insert : BinTree α → α → BinTree α
  | .empty, x => leaf x
  | .node v l r, x =>
    match compare x v with
    | .lt => BinTree.node v (insert l x) r
    | _ => BinTree.node v l (insert r x)
  -- sorry

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

Start with the Problem 57 reference and the List.foldl/BinTree.searchTreeFromList snippet in the issue. Locate the appropriate example in the repository, and consider the work complete when it clearly demonstrates a fold whose accumulator and element types differ.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.