This code reads the number of lines to process from the first line of stdin, then it executes a num_of_lines_to_process loop, doing some calculations and prints the result. I want him to print the line number in the line "#" after "#", but I donβt know how to get it.
import IO import Control.Monad (replicateM) main :: IO () main = do hSetBuffering stdin LineBuffering s <- getLine let number_of_lines_to_process = read s :: Integer lines <- replicateM (fromIntegral(number_of_lines_to_process)) $ do line <- getLine let number = read line :: Integer result = number*2
I assume the solution to this problem is very simple, but I am not familiar with Haskell (coding in it for the first time), and I have not found any way to do this. Can anyone help?
source share