Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate (or predefine) 'TimesSquare' types... #41

Open
librasteve opened this issue Jan 6, 2021 · 0 comments
Open

Automate (or predefine) 'TimesSquare' types... #41

librasteve opened this issue Jan 6, 2021 · 0 comments

Comments

@librasteve
Copy link
Owner

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 = u
t + (1/2) * a * tt; say ~s; #63 m
21 my \s = u
t + (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 * v
v;
27
28 my \Δke = ke2 - ke1;
29 (pe cmp Δke).say; #Same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant