[Pharo-dev] [Inspiration] Toward a better programming

Sven Van Caekenberghe sven at stfx.eu
Sat Apr 26 13:14:56 EDT 2014


On 29 Mar 2014, at 11:31, Sven Van Caekenberghe <sven at stfx.eu> wrote:

> | input |
> input := #(2 4 4 4 5 5 7 9).
> (((input - input average) raisedTo: 2) sum / (input size - 1)) sqrt.

Shorter, simpler using #squared :

| input |
input := #(2 4 4 4 5 5 7 9).
((input - input average) squared sum / (input size - 1)) sqrt.

I just found out that we already have #stdev in the 3.0 image :

#(2 4 4 4 5 5 7 9) stdev.

;-)





More information about the Pharo-dev mailing list