我在让随机数生成器工作时遇到问题,我不知道为什么。我必须在学校的实验室中执行此操作,并且该程序应该通过随机选择下一个状态来打印非确定性转换系统的轨迹。谁能告诉我这有什么问题?
import qualified Data.Set as Set
import System.Random (StdGen)
import qualified System.Random as Random
rngTrace :: Int -> TrSys a -> a -> [a]
rngTrace r tr c =
c : List.unfoldr next c
where
next c =
let cs = tr c in
if null cs then Nothing else Just (Set.elemAt s cs, Set.elemAt s cs )
where
s:ss = Random.randomRs (0, Set.size (tr c) ) (Random.mkStdGen r)