Consider this... only works ootb with t * t and not t ** 2
1 #!/usr/bin/env raku
2 use lib '../lib';
3 use Physics::Measure :ALL;
4
5 GetMeaUnit('s^2').NewType('TimesSquare');
6 class TimesSquare is Measure {}
7 GetMeaUnit('m^2/s^2').NewType('SpeedSquare');
8 class SpeedSquare is Measure {}
9
10 my \d = 42m; say ~d; #42 m
11 my \t = 10s; say ~t; #10 s
12
13 my \u = d / t; say ~u; #4.2 m/s
14 my \a = u / t; say ~a; #0.42 m/s^2
15
16 my \m = 25kg; say ~m; #25 kg
17 my \f = m a; say ~f; #10.5 N
18
19 my \v = u + at; say ~v; #8.4 m/s
20 ##my \s = ut + (1/2) a tt; say ~s; #63 m
21 my \s = ut + (1/2) a * t*2; say ~s; #63 m
22
23 my \pe = f s; say ~pe; #661.5 J
24
25 my \ke1 = (1/2) m uu;
26 my \ke2 = (1/2) m vv;
27
28 my \Δke = ke2 - ke1;
29 (pe cmp Δke).say; #Same
Consider this... only works ootb with t * t and not t ** 2
1 #!/usr/bin/env raku 2 use lib '../lib'; 3 use Physics::Measure :ALL; 4 5 GetMeaUnit('s^2').NewType('TimesSquare'); 6 class TimesSquare is Measure {} 7 GetMeaUnit('m^2/s^2').NewType('SpeedSquare'); 8 class SpeedSquare is Measure {} 9 10 my \d = 42m; say ~d; #42 m 11 my \t = 10s; say ~t; #10 s 12 13 my \u = d / t; say ~u; #4.2 m/s 14 my \a = u / t; say ~a; #0.42 m/s^2 15 16 my \m = 25kg; say ~m; #25 kg 17 my \f = m a; say ~f; #10.5 N 18 19 my \v = u + at; say ~v; #8.4 m/s 20 ##my \s = ut + (1/2) a tt; say ~s; #63 m 21 my \s = ut + (1/2) a * t*2; say ~s; #63 m 22 23 my \pe = f s; say ~pe; #661.5 J 24 25 my \ke1 = (1/2) m uu; 26 my \ke2 = (1/2) m vv; 27 28 my \Δke = ke2 - ke1; 29 (pe cmp Δke).say; #Same