- 宿題
- 3点のPointから、それらを点を結んだ時の三角形の面積を求める関数を実装してください。
data Point = Point Float Float
data Triangle = Triangle Point Point Point
length' :: String -> Int | |
length' = foldl (\ x _ -> x + 1) 0 | |
last' :: Show a => [a] -> (Maybe a) | |
last' = foldl (\ _ x -> Just x) Nothing | |
head' :: Show a => [a] -> (Maybe a) | |
head' [] = Nothing | |
head' (x:_) = Just x |
import System.Random | |
dice :: StdGen -> Int | |
dice gen = num | |
where (num, _) = diceWithRandomGen gen | |
diceWithRandomGen :: StdGen -> (Int, StdGen) | |
diceWithRandomGen = randomR (1, 6) | |
threeTimesDiceRoll :: StdGen -> (Int, Int, Int) |