Add tags

Add tags to the following comment

きっともっと綺麗な書き方があると思うのですが、挑戦の意味を込めて投稿です。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import System.Random
import Text.Printf

direction = [(1, 0), (0, 1), (-1, 0), (0, -1)]

printPoint :: (Int, (Int, Int)) -> IO ()
printPoint (n, (x, y)) = printf "%4d%4d%4d¥n" n x y

addPair (x1, y1) (x2, y2) = (x1 + x2, y1 + y2)

main = do
  gen <- getStdGen
  mapM_ printPoint $ take 10 $ zip [1..] $ scanl addPair (0, 0) $ map (\x -> direction !! (mod x 4)) $ randoms gen

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...