Skip to content

Commit 77f83f3

Browse files
author
Oskar Lundström
committed
Renare derivering
1 parent c687c8e commit 77f83f3

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

Physics/src/Combination/Combination.hs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,47 +39,44 @@ t1 :: Quantity Length FunExpr
3939
t1 = (Const 5 :+ Const 2 :* Id) # length
4040

4141
-- eller kortare
42-
type CQ d = Quantity d FunExpr
42+
type QC d = Quantity d FunExpr
4343

44-
t2 :: CQ Length
44+
t2 :: QC Length
4545
t2 = t1
4646

4747
-- Ett flygplan i turbulens
48-
t3 :: CQ Length
48+
t3 :: QC Length
4949
t3 = 5 + sin Id # length
5050

5151
-- Ett flygplan som står stilla
52-
t4 :: CQ Length
52+
t4 :: QC Length
5353
t4 = 8 # length
5454

5555
type Area = Length `Mul` Length
5656

5757
-- Någon slags multiplikation
58-
t5 :: CQ Area
58+
t5 :: QC Area
5959
t5 = t1 *# t3
6060

61-
t6 :: CQ Area
61+
t6 :: QC Area
6262
t6 = fmap simplify t5
6363

6464
-- Någon slags division
65-
t7 :: CQ Length
65+
t7 :: QC Length
6666
t7 = t6 /# t4
6767

6868
-- Går ej, vilket är bra
69-
-- t8 :: CQ Area
69+
-- t8 :: QC Area
7070
-- t8 = t6 /# t4
7171

72-
-- Stöd för derivering. Hela CQ och dessa
72+
-- Stöd för derivering. Hela QC och dessa
7373
-- bör vara dola för utomstående användare.
74-
-- Inuti är "otypat". Wrap och unwrap borde vara "protected" och inte "public", Java analogi.
75-
76-
differentiateWRTtime :: CQ d -> CQ (d `Div` Time)
77-
differentiateWRTtime cq = newWithNewQuantity
78-
where
79-
originalWithQuantity = cq
80-
newWithQuantity = fmap derive cq
81-
newWithoutQuantity = unwrap newWithQuantity
82-
newWithNewQuantity = wrap newWithoutQuantity (originalWithQuantity /# time)
74+
75+
-- fmap på Quantity, men inte QC!
76+
77+
differentiateWRTtime :: QC d -> QC (d `Div` Time)
78+
differentiateWRTtime qc = fmap simplify $ fmap derive qc /# time
79+
8380

8481

8582

0 commit comments

Comments
 (0)