{-|
Module : 1JC3-Assign1.Assign_1.hs
Copyright : (c) Curtis D’Alves 2021
License : GPL (see the LICENSE file)
Maintainer : none
Stability : experimental
Portability : portable
Description:
Assignment 1 – McMaster CS 1JC3 2021
-}
module Assign_1 where
import Prelude hiding (sin,cos,tan)
———————————————————————————————————–
— INSTRUCTIONS README!!!
———————————————————————————————————–
— 1) DO NOT DELETE/ALTER ANY CODE ABOVE THESE INSTRUCTIONS
— 2) DO NOT REMOVE / ALTER TYPE DECLERATIONS (I.E THE LINE WITH THE :: ABOUT THE FUNCTION DECLERATION)
— IF YOU ARE UNABLE TO COMPLETE A FUNCTION, LEAVE IT’S ORIGINAL IMPLEMENTATION (I.E. THROW AN ERROR)
— 3) MAKE SURE THE PROJECT COMPILES (I.E. RUN STACK BUILD AND MAKE SURE THERE ARE NO ERRORS) BEFORE
— SUBMITTING, FAILURE TO DO SO WILL RESULT IN A MARK OF 0
— 4) REPLACE macid = “TODO” WITH YOUR ACTUAL MACID (EX. IF YOUR MACID IS jim THEN macid = “jim”)
———————————————————————————————————–
macid :: String
macid = “TODO”
{- —————————————————————–
– factorial
– —————————————————————–
– Description:
– Computes the factorial of any Integer n
– —————————————————————–
– | Input | |
– | n | Integer input |
– —————————————————————–
– | Output | |
– | n <= 1 | 1 |
- | n > 1 | n * (n-1) … * 1 while (n-k) > 0 |
– —————————————————————–
-}
factorial :: Integer -> Integer
factorial n = if n > 0
then n * factorial (n-1)
else 1
{- ——————————————————————
– sinTaylor
– ——————————————————————
– Description:
– TODO add comments
-}
sinTaylor :: Double -> Double -> Double -> Double -> Double
sinTaylor a cos_a sin_a x = error “TODO implement sinTaylor”
{- —————————————————————–
– fmod
– —————————————————————–
– Description:
– TODO add comments
-}
fmod :: Double -> Double -> Double
fmod x y =
let
— z is the largest integer s.t. z*y <= x
-- HINT use floating point division, then round down
z = error "TODO implement fmod"
in x - z*y
{- ----------------------------------------------------------------------
- sinApprox
- ----------------------------------------------------------------------
- Description:
- TODO add comments
-}
sinApprox :: Double -> Double
sinApprox x = error “TODO implement sinApprox”
{- ———————————————————————
– sinApprox
– ———————————————————————
– Description:
– TODO add comments
-}
cosApprox :: Double -> Double
cosApprox x = error “TODO implement cosApprox”
{- ———————————————————————
– tanApprox
– ———————————————————————
– Description:
– TODO add comments
-}
tanApprox :: Double -> Double
tanApprox x = error “TODO implement tanApprox”