-
Notifications
You must be signed in to change notification settings - Fork 0
/
Random.hs
40 lines (34 loc) · 7.39 KB
/
Random.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module Random (randomList) where
import System.Random
{-
Modulo do primeiro trabalho computacional de Programação Funcional em Haskell responsável pela
geração de lista randomica.
-}
tem :: Eq a => a -> [a] -> Bool
tem _ [] = False
tem y (x:xs)
| x == y = True
| otherwise = tem y xs
removeDup :: Eq a => [a] -> [a]
removeDup l = removeD l []
where
removeD [] _ = []
removeD (x:xs) ls
| tem x ls = removeD xs ls
| otherwise = x: removeD xs (x:ls)
randomList:: Int -> Int -> Int -> [Int]
{--
-- Testes com os indices iguais ao do professor, na base iris (4 primeiros), na base wine (4 próximos) e na base breast (último).
randomList _ 28 _ = [65,3,24,51,135,117,69,79,82,148,108,78,62,137,107,84,36,33,143,129,126,134,123,97,31,9,64,35,43,93,128,6,2,144,29,103,1,146,48,67,32,136,139,70,57,83,109,23,114,96,59,111,4,101,0,55,105,95,14,125,27,10,28,7,80,8,22,72,13,85,120,63,54,102,94,66,44,53,25,92,110,98,131,15,40,49,30,124,73,75,113,118,21,90,38,61,42,41,115,127,5,12,81,89,71,133,142,47,87,106,34,130,18,20,141,140,100,46,149,16,91,104,52,138,60,119,145,76,11,56,112,88,99,74,39,68,50,132,58,37,116,122,121,77,147,17,26,86,19,45]
randomList _ 42 _ = [48,95,15,145,23,139,50,133,142,41,94,92,91,127,66,9,75,122,24,74,31,34,72,107,125,119,38,3,97,86,80,77,65,58,131,135,132,105,29,13,27,18,44,28,98,69,115,146,40,83,136,82,62,45,106,46,129,51,63,55,47,87,117,1,52,134,103,89,120,88,79,35,43,22,76,30,138,68,109,123,85,25,56,84,60,7,118,126,143,141,54,0,90,73,11,2,147,108,140,128,12,16,78,36,4,39,53,137,130,113,148,20,21,112,70,149,104,96,59,8,101,100,37,124,19,42,121,102,93,26,57,33,32,6,114,5,49,67,116,111,64,61,14,17,71,144,99,110,81,10]
randomList _ 65 _ = [124,48,70,63,95,77,134,111,25,127,51,115,107,65,104,71,144,22,122,40,32,68,143,80,137,56,87,34,116,55,57,86,130,18,28,149,50,97,141,58,60,31,110,93,27,126,133,138,98,131,37,75,105,109,6,5,16,118,142,78,108,88,19,128,54,140,121,12,11,43,136,30,129,46,119,2,42,23,96,83,0,132,85,29,38,49,66,44,64,112,62,53,52,17,35,14,102,10,117,148,101,3,82,41,135,94,79,91,4,7,26,114,24,1,100,20,74,39,15,61,92,145,81,72,33,120,113,90,36,47,59,9,125,76,73,99,84,21,139,69,8,67,147,89,123,146,106,103,13,45]
randomList _ 77 _ = [121,64,120,60,101,62,122,49,116,36,45,134,58,87,50,13,91,83,16,24,22,86,3,107,138,115,113,70,55,84,17,59,131,34,37,137,142,10,5,96,79,52,75,14,48,130,40,100,89,32,51,46,21,35,110,8,126,105,117,43,94,39,69,61,106,30,28,57,9,47,42,119,26,102,67,140,112,103,143,127,146,53,109,56,29,128,148,4,0,11,12,104,145,65,63,133,38,92,85,77,15,33,118,74,19,81,18,125,144,114,27,147,149,99,44,108,123,132,72,73,88,23,66,93,76,95,2,25,41,80,82,129,90,31,124,141,1,54,20,135,71,98,6,97,111,78,136,7,139,68]
randomList _ 13 _ = [63,1,90,91,150,60,144,5,164,7,11,16,176,22,143,4,21,152,155,58,51,8,30,18,20,15,12,149,52,131,86,65,168,145,72,102,67,93,59,165,53,138,68,139,0,2,3,6,9,10,13,14,17,19,23,24,25,26,27,28,29,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,54,55,56,57,61,62,64,66,69,70,71,73,74,75,76,77,78,79,80,81,82,83,84,85,87,88,89,92,94,95,96,97,98,99,100,101,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,132,133,134,135,136,137,140,141,142,146,147,148,151,153,154,156,157,158,159,160,161,162,163,166,167,169,170,171,172,173,174,175,177]
randomList _ 44 _ = [71,147,157,159,1,39,110,137,61,22,86,162,47,167,34,107,46,40,108,9,56,174,146,177,120,73,37,132,140,55,121,141,168,94,24,124,91,128,6,117,49,109,169,25,151,44,122,90,38,30,155,70,5,83,66,78,41,89,142,15,45,63,74,11,64,13,65,57,156,105,99,129,150,87,153,119,106,48,95,16,98,130,20,27,81,116,28,113,52,148,172,103,123,3,59,72,152,134,35,111,54,100,163,93,36,14,101,62,21,23,50,170,31,84,76,67,176,173,96,43,102,144,138,131,149,104,77,12,2,51,127,154,79,139,133,58,92,32,10,7,85,115,164,125,166,26,158,18,97,82,75,8,165,161,145,0,60,143,112,118,33,29,136,135,69,114,17,171,19,53,68,4,42,160,126,88,80,175]
randomList _ 68 _ = [147,133,49,9,165,120,57,60,44,92,113,139,126,17,30,119,135,158,155,37,142,104,70,93,117,41,169,156,29,129,176,28,145,90,83,170,172,89,121,141,48,146,35,76,124,159,108,4,103,63,130,20,140,87,137,34,94,128,14,136,19,81,58,166,59,86,173,151,118,23,171,0,1,2,3,5,6,7,8,10,11,12,13,15,16,18,21,22,24,25,26,27,31,32,33,36,38,39,40,42,43,45,46,47,50,51,52,53,54,55,56,61,62,64,65,66,67,68,69,71,72,73,74,75,77,78,79,80,82,84,85,88,91,95,96,97,98,99,100,101,102,105,106,107,109,110,111,112,114,115,116,122,123,125,127,131,132,134,138,143,144,148,149,150,152,153,154,157,160,161,162,163,164,167,168,174,175,177]
randomList _ 50 _ = [5,63,67,140,157,92,91,142,141,14,84,45,6,11,95,32,89,93,97,0,105,81,9,103,170,35,148,44,80,135,119,85,52,104,76,131,133,169,19,106,113,86,87,150,43,152,120,59,51,158,68,99,126,128,62,107,70,101,34,25,114,3,69,30,82,78,171,117,79,154,7,112,47,108,159,146,64,167,74,77,110,37,83,102,23,173,75,165,115,1,2,4,8,10,12,13,15,16,17,18,20,21,22,24,26,27,28,29,31,33,36,38,39,40,41,42,46,48,49,50,53,54,55,56,57,58,60,61,65,66,71,72,73,88,90,94,96,98,100,109,111,116,118,121,122,123,124,125,127,129,130,132,134,136,137,138,139,143,144,145,147,149,151,153,155,156,160,161,162,163,164,166,168,172,174,175,176,177]
randomList _ 89 _ = [565,445,234,561,150,331,141,57,89,40,520,496,74,270,345,248,178,229,125,205,492,368,564,102,148,250,318,438,471,195,376,513,24,117,236,530,485,426,88,100,314,110,120,508,30,139,147,20,49,272,394,170,483,58,527,555,130,239,468,238,411,430,43,489,93,491,349,501,525,406,478,286,211,338,218,304,269,495,48,188,96,22,472,465,87,82,291,315,214,529,439,462,111,536,474,216,364,10,146,549,365,161,384,562,341,335,142,490,109,119,232,295,423,532,511,552,160,31,294,277,476,138,176,92,317,419,223,303,203,157,257,136,79,244,17,534,432,389,165,200,114,112,207,332,26,105,502,547,526,448,361,6,383,509,418,115,475,132,282,399,62,55,342,363,61,455,280,278,182,15,428,287,515,402,171,34,44,41,135,391,145,118,328,190,420,292,264,149,327,276,154,396,499,568,78,237,189,198,281,283,51,209,11,144,251,256,306,35,25,409,412,431,546,300,417,429,199,228,369,450,90,544,334,460,131,226,193,73,222,151,554,451,242,4,518,407,440,76,217,38,519,14,97,388,259,543,129,108,241,385,164,379,5,425,512,175,308,504,163,53,184,397,367,370,482,84,159,337,558,208,265,106,123,436,231,541,336,313,464,252,309,302,401,9,72,414,344,537,494,324,128,215,296,18,307,548,263,187,378,516,528,422,0,375,325,507,158,99,506,340,16,274,98,443,2,421,7,453,416,348,267,60,23,121,113,219,225,463,103,86,497,343,293,355,381,387,484,122,330,140,479,316,152,481,321,204,359,461,168,253,550,80,42,553,444,521,449,427,333,456,505,493,310,320,77,395,382,177,466,442,366,183,243,95,262,39,66,212,390,104,126,322,162,83,410,538,319,275,373,230,174,81,64,398,56,459,65,357,437,360,386,447,551,249,143,433,408,323,247,91,13,311,434,255,517,488,71,155,567,400,469,305,372,191,59,185,45,560,37,245,19,510,254,266,358,346,201,487,347,221,503,531,353,424,1,279,46,329,21,153,371,452,404,467,559,374,233,94,535,50,297,480,540,156,413,179,63,435,54,299,202,213,235,500,470,312,227,271,68,354,240,127,289,393,339,284,69,356,47,133,169,539,514,3,75,556,380,563,542,290,273,352,473,458,52,415,28,173,124,557,67,405,137,172,107,27,446,566,33,522,180,246,533,362,167,192,220,12,116,498,181,524,36,85,441,523,260,197,288,298,350,194,301,351,486,196,32,457,101,326,377,29,545,70,166,268,454,186,206,261,134,477,224,403,285,210,392,8,258]
--}
randomList n s limite = take n $ removeDup $ randomRs (0,limite) g :: [Int]
where
g = mkStdGen s