File tree Expand file tree Collapse file tree 5 files changed +46
-33
lines changed
Expand file tree Collapse file tree 5 files changed +46
-33
lines changed Original file line number Diff line number Diff line change 772024-06-15 00:27:00.787216000000 [39436(ThreadId 17)] ERROR APP - start debugging failed. user error (ExecResult not found.) : Left "user error (ExecResult not found.)"
882024-06-15 00:30:49.937170000000 [40083(ThreadId 16)] CRITICAL REQUEST - invalid HANDLE. eof.
992024-06-15 00:31:21.254897000000 [40466(ThreadId 16)] CRITICAL REQUEST - invalid HANDLE. eof.
10+ 2024-06-27 10:15:11.049245000000 [65370(ThreadId 16)] CRITICAL REQUEST - invalid HANDLE. eof.
Original file line number Diff line number Diff line change 1+ {-# LANGUAGE FlexibleInstances, UndecidableInstances, DuplicateRecordFields #-}
2+
3+ module HelloWorld (mainHW ) where
4+
5+ import Control.Monad
6+
7+ helloWorlds :: (Num n , Eq n ) => n -> IO () -> IO ()
8+ helloWorlds 0 _ = return ()
9+ helloWorlds n action = do
10+ action
11+ helloWorlds (n - 1 ) action
12+
13+ helloWorlds2 :: Int -> IO () -> IO ()
14+ helloWorlds2 n action = do
15+ forM_ [1 .. n] $ \ _ -> action
16+
17+ helloWorlds3 :: Int -> IO () -> IO ()
18+ helloWorlds3 n action = mapM_ (const action) [1 .. n]
19+
20+ mainHW :: IO ()
21+ mainHW = do
22+ n <- readLn :: IO Int
23+ helloWorlds n $ putStrLn " Hello World"
24+ --- also
25+ sequence_ $ replicate n $ putStrLn " Hello World"
26+ -- also
27+ replicateM_ n (putStrLn " Hello World" )
28+ -- also
29+ helloWorlds2 n $ putStrLn " Hello World"
30+ -- also
31+ helloWorlds3 n $ putStrLn " Hello World"
Original file line number Diff line number Diff line change 1+ module ListReplication (mainLR ) where
2+
3+ -- Given a list, repeat each element in the list amount of times.
4+ f :: Int -> [Int ] -> [Int ]
5+ f n arr = concatMap (replicate n) arr
6+
7+ mainLR :: IO ()
8+ mainLR = getContents >>=
9+ mapM_ print . (\ (n: arr) -> f n arr). map read . words
Original file line number Diff line number Diff line change 22
33module Main (main ) where
44
5- import Control.Monad
6- import Data.Array
7- import Data.Bits
8- import Data.List
9- import Data.List.Split
10- import Data.Set
11- import Debug.Trace
12- import System.Environment
13- import System.IO
14- import System.IO.Unsafe
5+ -- import HelloWorld(mainHW)
6+ import ListReplication (mainLR )
157
168
17- helloWorlds :: (Num n , Eq n ) => n -> IO () -> IO ()
18- helloWorlds 0 _ = return ()
19- helloWorlds n action = do
20- action
21- helloWorlds (n - 1 ) action
22-
23- helloWorlds2 :: Int -> IO () -> IO ()
24- helloWorlds2 n action = do
25- forM_ [1 .. n] $ \ _ -> action
26-
27- helloWorlds3 :: Int -> IO () -> IO ()
28- helloWorlds3 n action = mapM_ (const action) [1 .. n]
29-
309main :: IO ()
3110main = do
32- n <- readLn :: IO Int
33- helloWorlds n $ putStrLn " Hello World"
34- --- also
35- sequence_ $ replicate n $ putStrLn " Hello World"
36- -- also
37- replicateM_ n (putStrLn " Hello World" )
38- -- also
39- helloWorlds2 n $ putStrLn " Hello World"
40- -- also
41- helloWorlds3 n $ putStrLn " Hello World"
11+ mainLR
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ executable voidhask-exe
4747 other-modules :
4848 Fun
4949 Functions
50+ HelloWorld
51+ ListReplication
5052 Main01
5153 MtlEx
5254 Paths_voidhask
You can’t perform that action at this time.
0 commit comments