[swift-users] Swift BMI
Gage Morgan
gagemorgan at outlook.com
Tue Dec 15 14:35:34 CST 2015
I understand that mine is a bit more complicated than it needs to be. It works, that's good enough for me. It gives proper values. I knew SOMEONE would have an issue with the "breaking machine," and I realized it could not be reached before typing it. I put it in there as a joke, nothing more (I've done worse in actual C).
As for types and other stuff, I will acknowledge that there could possibly be up to ten different revisions with much simpler code. I prefer to write things out, which is why there's not as many abstract concepts as some would like. I did as a test, just to see if it could be done. And the answer is yes, and that's good enough for me. The next time I plug in a formula I will consider these, but may not use them.
I understand your above points, but there are of course 14000 different ways that you could do it. Don't overthink it. I did it the way I did it because I could understand it, no intentions to be .selfless or take a .selfie whatsoever (THAT WAS A JOKE, FOR THE LOVE OF CHRIST).
There are many ways you can dumb it down. Unfortunately, abstraction and I don't play nice. So it would make sense for me to have written it out step-by-step. Look at the calculations given by the second revision. They are unrounded versions of the CDC website's results, are they not?
Sent from Outlook Mobile
On Mon, Dec 14, 2015 at 9:50 PM -0800, "Gage Morgan via swift-users" <swift-users at swift.org> wrote:
And a more polished version:https://gist.github.com/MGageMorgan/c2166174be878e9cea78
Sent from Outlook Mobile
On Mon, Dec 14, 2015 at 7:20 PM -0800, "Gage Morgan via swift-users" <swift-users at swift.org> wrote:
For most languages I try out, my own version of "Hello World!" is a BMI calculator. Swift has passed, I encourage you to try it out.
There are two methods called towards the end of file:1) bmi.pounds(weight, height) - Replace numbers inside with your own if you want to test out in US Customary units.
2) bmi.kilograms(weight, height) - Replace numbers inside with your own if you want to test out in Metric units used everywhere outside the US.
You already get the gist, the bits can be found here:https://gist.github.com/anonymous/9284017644567c29c7f8
If there's a bug please let me know, but it works in IBM's Sandbox. (Yes, ALL code was written by me without help. Very close to C, just a bit laid back.)
--MGage--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151215/0b0562e5/attachment.html>
-------------- next part --------------
_______________________________________________
swift-users mailing list
swift-users at swift.org
https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
_______________________________________________
swift-users mailing list
swift-users at swift.org
https://lists.swift.org/mailman/listinfo/swift-users
More information about the swift-users
mailing list