About
higher order:- prim::Int->Bool prim n |n<1 = True |n==2 =False |otherwise = isprime n 2 isprime::Int->Int->Bool isprime n i |i > floor (sqrt(fromIntegral n)) =True |mod n i==0 = False |otherwise = isprime n (i+1)
dectobin:: Int->Int
dectobin n
|n<2 =n
|(mod n 2 ==1 || mod n 2 ==0) = mod n 2 +10*(dectobin (n div
2))
|otherwise =0
input from user:- findOddOccurrence :: Eq a => [a] -> a findOddOccurrence xs = head [x | x <- xs, odd (length (filter (==x) xs))] main :: IO () main = do putStrLn "Enter a list of elements separated by spaces:" input <- getLine let list = words input result = findOddOccurrence list putStrLn ("The number occurring an odd number of times is: " ++ result)
let xs = map read (words input) :: [Int]