[Python-ideas] Inline assignments using "given" clauses
marcidy at gmail.com
Sun May 13 14:53:20 EDT 2018
On Sun, May 13, 2018, 11:28 Brendan Barnwell <brenbarn at brenbarn.net> wrote:
> On 2018-05-13 04:23, Steven D'Aprano wrote:
> > In my experience mathematicians put the given *before* the statement:
> > Given a, b, c three sides of a triangle, then
> > Area = sqrt(s*(s-a)*(s-b)*(s-c))
> > where s = (a + b + c)/2 is the semi-perimeter of the triangle.
> > For the record, that is almost exactly what I wrote for a student
> > earlier today, and its not just me, it is very similar to the wording
> > used on both Wolfram Mathworld and Wikipedia's pages on Heron's Formula.
> > http://mathworld.wolfram.com/HeronsFormula.html
> > https://en.wikipedia.org/wiki/Heron%27s_formula
> > Putting "given" after the expression is backwards.
> Yes, but that's because we're ruling out the use of "where". At
> point I would be fine with "snicklefritz" as the keyword. The point is
> that I want to put SOMETHING after the expression, and this is not at
> all unusual. See for instance Wikipedia pages on the Reimann zeta
> gravitation equation
> compound interest
> If we have to use the word "given" even though the word mathematicians
> would use in that position is "where", that's not such a big deal.
it is a big deal. postfix requires more cognitive load, we will have no
idea up front what's going on except for trivial exames. more givens, more
if you think spending that is fine for you, I can't argue, but to say it
doesn't matter isn't correct.
2.exames which get far worse for complex cases. left for the for can be as
[ x + y for t in range(10) ... ]
x = 10
y = 20
[ x + y for t in range(10) ...]
up till you read ... you have no idea there even will be a substitution.
The lower is even worse, you think you know, but then have to redo the
whole problem with new information.
mathematicians don't just put the _word_ "given", they put givens, things
that are known or assumed to be true. Axioms and definitions, where
definitions assign names to values. This is for formal arguements.
reassigning values is handled in post fix occasionally once it is clear
what x and y are. but that's not what we are talking about if the name
doesn't exist already.
again, you want to use given, that's fine, but the math argument is wrong,
as is the "it doesn't matter" argument, assuming the current neurological
model for working memory continues to hold.
Maybe the difference is small, especially after familiarity sets in, but
that doesn't mean the difference in load isn't there. it will only
increase for more complex statements with more givens.
> Brendan Barnwell
> "Do not follow where the path may lead. Go, instead, where there is no
> path, and leave a trail."
> --author unknown
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas