I need to print the elements of odd index. Currently is printing index.
I don't understand how I can print elements of this index?
f :: [Int] -> [Int]
f lst = filter odd [0..length lst]
-- I can't edit this part
main = do
inputdata <- getContents
mapM_ (putStrLn. show). f. map read. lines $ inputdata
If you want to do this "on foot":
odds [] = []
odds [x] = []
odds (e1:e2:xs) = e2 : odds xs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With