Stable marriage problem: Difference between revisions

Content added Content deleted
(→‎{{header|Lua}}: Marked incomplete as perturbing the engagements and then checking for stability is not attempted)
Line 760: Line 760:
)</lang>
)</lang>


For most of this, males and females are both represented by indices. Rows of <code>Mprefs</code> are indexed by a male index and list female indices in priority order. Rows of <code>Fprefs</code> are indexed by a female index and list male indices in priority order. The same indices select the corresponding names from <code>GuyNames</code> and <code>GalNames</code>.
For most of this, males and females are both represented by indices. Rows of <code>Mprefs</code> are indexed by a male index and each contains a list female indices, in priority order. Rows of <code>Fprefs</code> are indexed by a female index and each contains a list male indices in priority order. These indices select the corresponding names from <code>GuyNames</code> and <code>GalNames</code>.


In <code>matchMake</code> (and <code>propose</code>), <code>engaged</code> identifies the gal each guy is engaged to (or <code>_</code> if that guy is not engaged). And, <code>fallback</code> identifies the column which has the next gal, in <code>Mprefs</code>, for that guy to propose to.
In <code>matchMake</code> (and <code>propose</code>), <code>engaged</code> identifies the gal each guy is engaged to (or <code>_</code> if that guy is not engaged). And, <code>fallback</code> identifies the column which has the next gal, in <code>Mprefs</code>, for that guy to propose to.