egison-4.1.3: test/lib/core/random.egi
assert "rands"
(all (`member` [1..10]) (take 5 (rands 1 10)))
assert "pureRand"
(member (pureRand 1 10) [1..10])
assertEqual "randomize" (randomize []) []
assert "randomize" (eqAs (multiset integer) (randomize [1, 2, 3]) [1, 2, 3])
assert "R.between"
(eqAs (multiset integer) (R.between 1 10) [1..10])
assert "R.multiset"
(member
(matchAll [1, 2] as R.multiset integer with $n :: $ns -> (n, ns))
[[(1, [2]), (2, [1])], [(2, [1]), (1, [2])]])
assertEqual "R.multiset"
(matchAll [1, 2] as R.multiset integer with #1 :: $ns -> ns)
[[2]]
assert "R.set"
(member
(matchAll [1, 2] as R.set integer with $n :: $ns -> (n, ns))
[[(1, [1, 2]), (2, [1, 2])], [(2, [1, 2]), (1, [1, 2])]])
assertEqual "R.set"
(matchAll [1, 2] as R.set integer with #1 :: $ns -> ns)
[[1, 2]]
assert "R.uncons"
(member (R.uncons [1, 2]) [(1, [2]), (2, [1])])
assert "R.head"
(member (R.head [1..10]) [1..10])
assert "R.tail"
(member
(R.tail [1..5])
[[ 2, 3, 4, 5],
[1, 3, 4, 5],
[1, 2, 4, 5],
[1, 2, 3, 5],
[1, 2, 3, 4 ]])
assert "f.rands"
(all (\x -> x >= 1.0 && x <= 2.0) (take 10 (f.rands 1.0 2.0)))
assert "f.pureRand"
(let x := f.pureRand 1.0 2.0 in x >= 1.0 && x <= 2.0)