Skip to content

Commit dfeb187

Browse files
committed
Sample examples
1 parent c6b596f commit dfeb187

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

‎Test/Computable.lean‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def logComputable {α : Type} [Lean.ToMessageData α] (prog : RandPCG IO α) : C
2020

2121
attribute [computable] sumTwo
2222

23-
run_cmd do logComputable sumTwoComputable
23+
run_cmd logComputable sumTwoComputable
2424

2525
@[computable]
2626
noncomputable
@@ -31,20 +31,20 @@ def unfoldSumTwo : MeasureTheory.Measure ℝ := rdo
3131

3232
attribute [computable] centred
3333

34-
run_cmd do logComputable (centredComputable 20)
34+
run_cmd logComputable (centredComputable 20)
3535

3636
attribute [computable] branchOn
3737

3838
run_cmd do logComputable (branchOnComputable 20)
3939

40-
run_cmd do logComputable (branchOnComputable (-1))
40+
run_cmd logComputable (branchOnComputable (-1))
4141

4242
attribute [computable] fairCoin
4343

44-
run_cmd do logComputable (fairCoinComputable)
44+
run_cmd logComputable (fairCoinComputable)
4545

4646
attribute [computable] Bind.twoCoins
4747

48-
run_cmd do logComputable (Bind.twoCoinsComputable)
48+
run_cmd logComputable (Bind.twoCoinsComputable)
4949

5050
end Test.Computable

‎Test/Sample.lean‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module
2+
3+
public import RandomDo
4+
5+
set_option linter.style.header false
6+
7+
open NumLean IO Lean
8+
9+
run_cmd do
10+
let x ← rand 0 1000
11+
logInfo m!"Random number between 0 and 1000: {x}"
12+
13+
run_cmd do
14+
let x ← (runRandPCG <| randInt 1000 : IO Int)
15+
logInfo m!"Random number between 0 and 1000 (PCG): {x}"
16+
17+
run_cmd do
18+
let x ← (runRandPCG <| normal 10 2 : IO Float)
19+
logInfo m!"{x}"
20+
21+
run_cmd do
22+
let x ← (runRandPCG <| exponential 10 : IO Float)
23+
logInfo m!"{x}"
24+
25+
run_cmd do
26+
let x ← (runRandPCG <| binomial 10 0.5 : IO Nat)
27+
logInfo m!"{x}"
28+
29+
run_cmd do
30+
let x ← (runRandPCG <| bernoulli 0.5 : IO Nat)
31+
logInfo m!"{x}"

0 commit comments

Comments
 (0)