Created
October 8, 2018 20:20
-
-
Save fardinshikhiyev/266af30ade0deaf7908c708d5f230bc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module hw7 | |
import StdEnv | |
occurences :: [Int] Int -> [[Int]] | |
occurences [] i = [] | |
occurences x i = [[hd x] ++ [count] ++ [freq] ] ++ occurences ( filter ( (<>) (hd x) ) (tl x) ) i | |
where | |
count = length( filter( (==) (hd x) ) x ) | |
freq = count * 100 / i | |
MakeFrequenceTable :: [Int] -> [[Int]] | |
MakeFrequenceTable [] = [] | |
MakeFrequenceTable x = occurences x (length x) | |
Start = MakeFrequenceTable [1,3,2,3,2] // [[1,1,20],[3,2,40],[2,2,40]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment