Skip to content

Commit

Permalink
Make random apply seed using time (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
KortanZ authored May 4, 2024
1 parent 2830b4e commit 355fb26
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/org-roam/core/utils/random.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@

---@class org-roam.core.utils.Random
local M = {}
local seeded = false

---@param m integer
---@param n integer
---@return integer
function M.random(m, n)
if seeded == false then
-- https://www.lua-users.org/wiki/MathLibraryTutorial
math.randomseed(tonumber(tostring(os.time()):reverse():sub(1,6)))
seeded = true
end
return math.random(m, n)
end

Expand Down

0 comments on commit 355fb26

Please sign in to comment.