Quellcode durchsuchen

exercise 2.2 and 2.3: x(t) and v(t) for a rock thrown upwards at 30 m/s

George C. Privon vor 2 Jahren
Ursprung
Commit
050b6ced45
2 geänderte Dateien mit 34 neuen und 0 gelöschten Zeilen
  1. 15 0
      02-basicfunctions/exercises/ex2.2.hs
  2. 19 0
      02-basicfunctions/exercises/ex2.3.hs

+ 15 - 0
02-basicfunctions/exercises/ex2.2.hs

@@ -0,0 +1,15 @@
+-- Exercise 2.2
+-- George C. Privon
+-- 2023-09-05
+
+-- Define a constant
+e :: Double
+e = exp 1
+
+-- Define a function
+square :: Double -> Double
+square x = x ^ 2
+
+-- height of rock as a function of time, with a starting upward speed of 30 m/s
+yRock30 :: Double -> Double
+yRock30 t = 0.5 * (-9.8) * square t + 30 * t

+ 19 - 0
02-basicfunctions/exercises/ex2.3.hs

@@ -0,0 +1,19 @@
+-- Exercise 2.3
+-- George C. Privon
+-- 2023-09-05
+
+-- Define a constant
+e :: Double
+e = exp 1
+
+-- Define a function
+square :: Double -> Double
+square x = x ^ 2
+
+-- height of rock as a function of time, with a starting upward speed of 30 m/s
+yRock30 :: Double -> Double
+yRock30 t = 0.5 * (-9.8) * square t + 30 * t
+
+-- velocity of rock as a function of time
+vRock30 :: Double -> Double
+vRock30 t = (-9.8) * t + 30