(* vim: syntax=sml A structure for treating books as ORDERED types. $Id: Book.sml,v 1.1 2004/09/09 21:15:11 cstork Exp $ Copyright (c) 2003-2004 by Peter H. Froehlich . All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. *) structure Book: ORDERED = struct type t = { author: string, title: string, year: int, isbn: string }; fun compare {author=ax, title=tx, year=yx, isbn=ix} {author=ay, title=ty, year=yy, isbn=iy} = if ax < ay then LESS else if ax > ay then GREATER else if tx < ty then LESS else if tx > ty then GREATER else if yx < yy then LESS else if yx > yy then GREATER else if ix < iy then LESS else if ix > iy then GREATER else EQUAL; end;