Since haskell is a list-based language, there are many ways to work with lists. This article details some of the most interesting ways to multiply each number in a list by 5.
main:: IO() main = do mutable <- M.replicate 256 1 forM_ ([1..256] z-> modify mutable (x->x*5) z )
multiplyList :: [Int] -> [Int] multiplyList xs = map (\x->x*5) xs
multiplyList :: [Int] -> [Int] multiplyList = map (*5)
multiplyList :: [Int] -> [Int] multiplyList xs = xs >>= (\x -> [x*5])
m=(<$>)(*5)
multiplyList :: [Int] -> [Int] multiplyList xs = [x*5 | x <- xs]
multiplyList :: [Int] -> [Int] multiplyList xs = do x <- xs return $ x*5
multiplyList :: [Int] -> [Int] multiplyList xs = fmap (\x -> x*5) xs
multiplyList :: [Int] -> [Int] multiplyList xs = pure (\x->x*5) <*> xs
multiplyList :: [Int] -> [Int] multiplyList [] = [] multiplyList (x:xs) = (x*5) : multiplyList xs