Drasil icon indicating copy to clipboard operation
Drasil copied to clipboard

Projectile redux

Open JacquesCarette opened this issue 2 years ago • 3 comments

It would be "nice" to be able to also obtain this version of projectile:

import math

v, t, p1 = 5.1, 43.0, 12.89
d = 2.0 * v ** 2.0 * math.sin(t) * math.cos(t) / 9.8 - p1
if (math.fabs(d / p1) < 2.0e-2) :
    return "The target was hit."
elif (d < 0.0) :
    return "The projectile fell short."
else :
    return "The projectile went long."

It is, on purpose, rather hideous. [I didn't take the values from the standard input file, I should probably do that.] Nevertheless, we should be able to set options and write a recipe that produces this. (Though maybe those returns should be prints ?)

JacquesCarette avatar Jan 27 '23 02:01 JacquesCarette

Yes, I agree. We should be able to produce a simple "bare bones" version of the program. No separate files. No classes. No functions. Just the requirements in the sequence they are listed (input, calculate, output). Some people might say that this simple program should be written like you have it above. The way we currently do it we make a simple program look much more complex than it has to.

smiths avatar Jan 27 '23 03:01 smiths

Duplicate of #1999, closing, but as always, feel free to re-open if you feel otherwise.

balacij avatar Apr 26 '23 15:04 balacij

Actually, this is related to, but different. That asks for unmodular, this asks for straight-line and with extra inlining.

JacquesCarette avatar Jun 28 '23 20:06 JacquesCarette