A classic example to construct the sequence of the square roots of the first integer numbers.
The Pharo sketch constructs a sequence of right triangles. The hypotenuses are the square roots.
| figure triangle |
figure := DrGeoSketch new fullscreen.
triangle := [:p1 :p2 :p3 :n |
|s1 s2 s3 perp cercle p4 |
s1 := figure segment: p1 to: p2.
s2 := (figure segment: p2 to: p3) color: Color red.
s3 := figure segment: p3 to: p1.
perp := (figure perpendicular: s3 at: p3) hide.
cercle := (figure circleCenter: p3 to: p2) hide.
p4 := (figure altIntersectionOf: cercle and: perp) hide.
n > 0 ifTrue:
[triangle value: p1 value: p3 value: p4 value: n -1]
].
triangle
value: 0@0
value: -1@0
value: -1@1
value: 50
An animated variation of this sketch: