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

デフォルト引数 ・オプション引数?の使用例

Open
#1,737 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

ふつうは指定したくないけど、いざとなれば簡単に変更できるという感じ。

def IO.randFloat (lo hi : Float) (base := 10000000) : IO Float := do
  -- `0`以上`1`未満の乱数を生成する
  let r := (← IO.rand 0 base : Float) / (base : Float)

  return (hi - lo) * r + lo

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 by locating the Lean example section covering function arguments and review how nearby examples are organized. Add a clear example explaining a default argument that is normally omitted but can be overridden, using the IO.randFloat example from the issue; done when the usage and override behavior are understandable from the documentation.

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
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.