Le 15/05/2019 à 20:37, Konrad Hinsen a écrit :
Lambda expressions are indeed Python's anonymous functions, but no Python programmer would create a lambda expression only to assign it to a variable. Doing this in an article to "sell" Smalltalk might well have the opposite effect.
Nor a Smalltalk programmer. Bellow the context for FYI. | sketch f df xn ptA ptB| sketch := DrGeoSketch new axesOn. xn := 2. f := [ :x | x cos + x ]. df := [ :x | (f value: x + 1e-8) - (f value: x) * 1e8]. "Derivate number" sketch plot: f from: -20 to: 20. ptA := (sketch point: xn@0) large; name: 'Drag me'. 5 timesRepeat: [ Â Â Â ptB := sketch point: [ :pt | pt point x @ (f value: pt point x)] parent: ptA. Â Â Â ptB hide. Â Â Â (sketch segment: ptA to: ptB) dotted forwardArrow . Â Â Â ptA := sketch point: [:pt | Â Â Â Â Â Â | x | Â Â Â Â Â Â x := pt point x. Â Â Â Â Â Â x - ( (f value: x) / (df value: x) )Â @ 0 ] parent: ptB. Â Â Â ptA hide. Â Â Â (sketch segment: ptB to: ptA) dotted forwardArrow]. -- Dr. Geo http://drgeo.eu