Index: doc/theses/mike_brooks_MMath/array.tex
===================================================================
--- doc/theses/mike_brooks_MMath/array.tex	(revision 33474e6e9cd77c01f702bed9fe6defd58b147a23)
+++ doc/theses/mike_brooks_MMath/array.tex	(revision d0296db634a9aed117c2b3772b0e298cd15fe6d5)
@@ -260,7 +260,16 @@
 \lstinput{10-15}{hello-accordion.cfa}
 This structure's layout has the starting offset of @studentIds@ varying according to the generic parameter @C@, and the offset of @preferences@ varying according to both generic parameters.
-For a function that operates on a @School@ structure, the type system handles this memory layout transparently.
-\lstinput{40-45}{hello-accordion.cfa}
+
+The school example has the data structure capturing many students' course-preference forms.
+It has course- and student-level metadata (their respective display names) and a position-based preferecens' matrix.
+The input files in \VRef[Figure]{f:checkHarness} give example data.
+
+When a function operates on a @School@ structure, the type system handles its memory layout transparently.
+\lstinput{30-37}{hello-accordion.cfa}
+In the running example, this @getPref@ function answers,
+for the student at position @sIx@, what is the position of its @pref@\textsuperscript{th}-favoured class?
+
 \VRef[Figure]{f:checkHarness} shows the @School@ harness and results with different array sizes.
+This example program prints the courses in each student's preferred order, all using the looked-up display names.
 Note the declaration of the @school@ variable.
 It is on the stack and its initialization does not use any casting or size arithmetic.
@@ -277,16 +286,33 @@
 \begin{tabular}{@{}ll@{\hspace{25pt}}l@{}}
 \begin{tabular}{@{}p{3.25in}@{}}
-\lstinput{60-64}{hello-accordion.cfa}
+\lstinput{50-55}{hello-accordion.cfa}
 \vspace*{-3pt}
-\lstinput{73-80}{hello-accordion.cfa}
+\lstinput{90-98}{hello-accordion.cfa}
 \end{tabular}
 &
 \raisebox{0.32\totalheight}{%
-\lstinput{85-93}{hello-accordion.cfa}
 }%
 &
-\lstinput{95-109}{hello-accordion.cfa}
 \end{tabular}
-\caption{\lstinline{school} Harness and Output}
+
+TODO: Get Peter's layout help
+
+\$ cat school1
+
+\lstinput{}{school1}
+
+\$ ./a.out < school1
+
+\lstinput{}{school1.out}
+
+\$ cat school2
+
+\lstinput{}{school2}
+
+\$ ./a.out < school2
+
+\lstinput{}{school2.out}
+
+\caption{\lstinline{School} harness, input and output}
 \label{f:checkHarness}
 \end{figure}
Index: doc/theses/mike_brooks_MMath/programs/hello-accordion.cfa
===================================================================
--- doc/theses/mike_brooks_MMath/programs/hello-accordion.cfa	(revision 33474e6e9cd77c01f702bed9fe6defd58b147a23)
+++ doc/theses/mike_brooks_MMath/programs/hello-accordion.cfa	(revision d0296db634a9aed117c2b3772b0e298cd15fe6d5)
@@ -2,5 +2,5 @@
 #include <stdlib.hfa>
 #include <array.hfa>
-#include <locale.h>							// setlocale
+#include <string.hfa>
 
 
@@ -8,20 +8,10 @@
 
 
-forall( [C], [S] ) $\C{// Class size, Students in class}$
+forall( [C], [S] ) $\C{// num courses, num students}$
 struct School {
-	@array( int, C )@ classIds; $\C{// nested VLAs}$
-	@array( int, S )@ studentIds;
-	@array( int, C, S )@ preferences; $\C{// multidimensional}$
+	@array@( string, C ) course_codes; $\C{// nested VLAs}$
+	@array@( string, S ) student_ids;
+	@array@( int, C, S ) preferences; $\C{// multidimensional}$
 };
-
-
-
-// TODO: understand (fix?) why these are needed (autogen seems to be failing ... is typeof as struct member nayok?)
-
-forall( [C], [S] )
-void ?{}( School( C, S ) & this ) {}
-
-forall( [C], [S] )
-	void ^?{}( School( C, S ) & this ) {}
 
 
@@ -39,8 +29,10 @@
 
 forall( [C], [S] )
-void put( @School( C, S ) & s@, int class, int student, int pref ) {
-	s.classIds[class] = class; $\C{// fields' offsets are dynamic }$
-	s.studentIds[student] = student;
-	s.preferences[class][student] = pref;
+int getPref( @School( C, S ) & school@, int is, int pref ) {
+    for ( ic; C ) {
+        int curPref = @school.preferences@[ic][is];   $\C{// offset calculation implicit}$
+		if ( curPref == pref ) return ic;
+	}
+    assert( false );
 }
 
@@ -56,23 +48,49 @@
 
 
+int main() {
+	int nc, ns;
+	sin | nc | " courses,";
+	sin | ns | " students";
+	@School( nc, ns ) school;@
+	// ... elided: read data into school
 
 
-int main() {
-	int classes, students;
-	sin | classes | students;
-	@School( classes, students ) school;@
-	// elided: read data into school, calling put
-	{	int class, student, preference;
-		// for each student's class/preferences
-		try {
-			for ( ) {
-				sin | class | student | preference;
-				put( school, class, student, preference );
-			}
-		} catch( end_of_file * ) {}	   }
-	for ( s; students ) {
-		sout | "student" | s | nonl;
-		for ( c; classes ) {
-			sout | school.preferences[c][s] | nonl;
+
+
+	{	string sv;
+        int iv;
+        // headers' row
+        sin | "\nc\\s";
+        for ( is ; ns ) {
+            // column label
+            sin | sv;
+            school.student_ids[is] = sv;
+        }
+        // body rows
+        for ( ic ; nc ) {
+            // row label
+            sin | sv;
+            school.course_codes[ic] = sv;
+            for ( is ; ns ) {
+                // matrix item
+                sin | iv;
+                school.preferences[ic][is] = iv;
+            }
+        }
+    }
+
+
+
+
+
+
+
+
+
+	for ( is; ns ) {
+		sout | school.student_ids[is] | ": " | nonl;
+		for ( pref; 1 ~= nc ) {
+            int ic = getPref(school, is, pref);
+            sout | school.course_codes[ ic ] | nonl;
 		}
 		sout | nl;
@@ -81,33 +99,4 @@
 
 
-
-/*
-$\$$ cat school1
-2 2
-0 0 1
-1 0 7
-0 1 12
-1 1 13
-$\$$ a.out < school1
-student 0 1 7
-student 1 12 13
-
-$\$$ cat school2
-3 3
-0 0 1
-1 0 7
-2 0 8
-0 1 12
-1 1 13
-2 1 14
-0 2 26
-1 2 27
-2 2 28
-$\$$ a.out < school2
-student 0 1 7 8
-student 1 12 13 14
-student 2 26 27 28
-*/
-
 // Local Variables: //
 // compile-command: "sed -f sedcmd hello-accordion.cfa > ../build/tmp.cfa; cfa ../build/tmp.cfa -Wall -Wextra" //
Index: doc/theses/mike_brooks_MMath/programs/school1
===================================================================
--- doc/theses/mike_brooks_MMath/programs/school1	(revision 33474e6e9cd77c01f702bed9fe6defd58b147a23)
+++ doc/theses/mike_brooks_MMath/programs/school1	(revision d0296db634a9aed117c2b3772b0e298cd15fe6d5)
@@ -1,5 +1,5 @@
-2 2
-0 0 1
-1 0 7
-0 1 12
-1 1 13
+3 courses, 2 students
+c\s     90111111 90222222
+ENGL101        3        2
+PHYS101        1        3
+CHEM101        2        1
Index: doc/theses/mike_brooks_MMath/programs/school1.out
===================================================================
--- doc/theses/mike_brooks_MMath/programs/school1.out	(revision d0296db634a9aed117c2b3772b0e298cd15fe6d5)
+++ doc/theses/mike_brooks_MMath/programs/school1.out	(revision d0296db634a9aed117c2b3772b0e298cd15fe6d5)
@@ -0,0 +1,2 @@
+90111111: PHYS101 CHEM101 ENGL101
+90222222: CHEM101 ENGL101 PHYS101
Index: doc/theses/mike_brooks_MMath/programs/school2
===================================================================
--- doc/theses/mike_brooks_MMath/programs/school2	(revision 33474e6e9cd77c01f702bed9fe6defd58b147a23)
+++ doc/theses/mike_brooks_MMath/programs/school2	(revision d0296db634a9aed117c2b3772b0e298cd15fe6d5)
@@ -1,10 +1,7 @@
-3 3
-0 0 1
-1 0 7
-2 0 8
-0 1 12
-1 1 13
-2 1 14
-0 2 26
-1 2 27
-2 2 28
+5 courses, 3 students
+c\s     90111111 90222222 90333333
+ENGL101        3        2        3
+PHYS101        1        3        4
+CHEM101        2        1        5
+PHIL101        4        5        2
+MATH499        5        4        1
Index: doc/theses/mike_brooks_MMath/programs/school2.out
===================================================================
--- doc/theses/mike_brooks_MMath/programs/school2.out	(revision d0296db634a9aed117c2b3772b0e298cd15fe6d5)
+++ doc/theses/mike_brooks_MMath/programs/school2.out	(revision d0296db634a9aed117c2b3772b0e298cd15fe6d5)
@@ -0,0 +1,3 @@
+90111111: PHYS101 CHEM101 ENGL101 PHIL101 MATH499
+90222222: CHEM101 ENGL101 PHYS101 MATH499 PHIL101
+90333333: MATH499 PHIL101 ENGL101 PHYS101 CHEM101
