Hey,

I think in python, you use Lambda Expressions. Here is how I would do it in python3:
import math
f = lambda x: math.cos(x) + x
d_f = lambda x: (f(x + 1e-8) - f(x)) * 1e8



On Wed, May 15, 2019 at 6:33 PM Hilaire <hilaire@drgeo.eu> wrote:
Hi,

We, Smalltalkers, use bloc of code as easily as we breathe air.

I am writing an article on Smalltalk programming for a French
mathematics teachers magazine.

To illustrate the simplicity of Smalltalk, I would like to compare how
the bloc of code 'f' and 'df' below will be implemented in Javascript
and Python:


f := [ :x | x cos + x ].
df := [ :x | (f value: x + 1e-8) - (f value: x) * 1e8].

Here f is a way to implement a function and df its derivate.

Do some of you knows how it will be written in Javascript and Python
with their own ad-hoc anonymous function?

Thanks

Hilaire

--
Dr. Geo
http://drgeo.eu