3 ms·
>As a simpler example, the other day I helped a high school student write a program to do basic numerical integration. No external input needed. So how are the
by zeth___ 8y ago
>As a simpler example, the other day I helped a high school student write a program to do basic numerical integration. No external input needed.
So how are the functions fed into the integrator? The second you want your program to integrate more than the one function you hard coded it with you need a parser to understand what the function is and then translate it into the internal language representation. Something that is very far from trivial.
- mkl 8y agoSure, but for most purposes, that kind of generality is just not needed. I have hundreds of useful small to large programs that don't need any external input - it's all in the source code. Besides, even if you want to take in a general function in this case, there's almost certainly no need to write a bespoke parser by hand. In fact, this student was able to handle that requirement just fine (he had this in there first, and we made the program more useful by taking it out): exec('f = lambda x: ' + input('Enter function: f(x) = ')) Writing parsers is simply not the universal programming requirement you claim. This will be my last reply in this thread.