Diversion: The Reconciliation Ball

Strip the willow is a dance involving 8 protagonists, four women and four men. They stand in line opposite each other as shown.

First Winnie and Nelson birl (link arms and rotate). Nelson then waits to the north while Winnie birls with Woody after which she birls again with her partner Nelson.

Winnie and Nelson move eastward down the middle. Winnie birls alternately with each of the men and her partner. Winnie birls with Ike then Nelson then Charles then Nelson. This completes the first pass. In the second pass Nelson birls with his partner Winnie and each woman in turn only in reverse order. (Winnie, Di, Winnie, Tina, Winnie, Mia). On the third pass Winnie birls with Woody while Nelson birls with Mia, then Nelson and Winnie birl with each other then with the next couple Tina and Ike, then with each other then with Di and Charles. This completes the third pass. After three passes Winnie and Nelson stand to the east and Mia and Woody repeat the procedure. The other two couple have there go in turn. Your program should output a string: "Winnie birls with Nelson. Winnie birls with Woody. Winnie birls with Nelson. Winnie birl with Ike...Di birls with Ike while Charles birls with Tina."

Diversion One: discussion & help

The solution outlined here is by no means the most elegant. Improvements - preferably using only the methods covered so far would be most welcome - mail andrew.
First a basic functions: fun birls(a,b) = a^" birls with "^b^"."; (* Test this with... *) birls("Winnie", "Nelson"); Both the first and the second pass involve five people. These are the birler, the birlers partner, and three bystanders. fun pass1or2(birler,partner,bs1,bs2,bs3) = birls(birler,partner)^birls(birler,bs1)^ birls(birler,partner)^... To factorize this definition we might define menage to be what three people do during pass one or two: fun menage(birler,partner,bs) = birls(birler,partner)^birls(birler,bs); fun pass1or2(birler,partner,bs1,bs2,bs3) = menage(birler,partner,bs1)^ menage(birler,partner,bs2)... By we can now perform passes one and two: fun pass1and2(w1,w2,w3,w4,m1,m2,m3,m4) = pass1or2(w1,m1,m2,m3,m4)^pass1or2(m1,w1,...); To save tedious typing in testing you might define the constant 8-tuple: val peeps = ("Winnie","Mia","Tina","Di","Nelson"... Now test with pass1and2 peeps; Pass three is different as we have two pairs doing it simultaneously. fun dbirl(b1,p1,b2,p2) = b1 ^" birls with " ^ p2 ^ " while " ^ p1 ^" birls with " ^ b2 ^ "."; A set of three passes can now be put together. To construct the other sets you may wish to use the rotate function: fun rotate(w1,w2,w3,w4,m1,m2,m3,m4) = (w2,w3,w4,w1,m2,m3,m4,m1); Note that on some systems only the first line or so of a string will be shown. You can see the whole string by entering print it;