Skip to content

Commit

Permalink
Simplify random steps
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCVanB committed Feb 20, 2022
1 parent b255e0c commit 96695ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/scatter.roc
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ pointCount = 100000
randomSeed = 123
min = 0
max = 100000
initial = { seed: ScatterRandom.seed32 randomSeed, value: randomSeed }
randomPoints = List.repeat pointCount 0
|> List.walk { previous: { seed: ScatterRandom.seed32 randomSeed, value: randomSeed }, values: [] } (\state, _ ->
now = ScatterRandom.step state.previous.seed (ScatterRandom.u32 min max)
|> List.walk { previous: initial, values: [] } (\state, _ ->
now = ScatterRandom.next state.previous (ScatterRandom.u32 min max)
x = Num.toFloat state.previous.value
y = Num.toFloat now.value
values = List.append state.values (P2 x y)
Expand Down

0 comments on commit 96695ca

Please sign in to comment.