I think there's a typo in the createQty function: shouldn't it return (uint16 0) if n is less than 0, not greater?
Otherwise, great article. This is exactly how I learned to program with Scheme: mosel the domain carefully, slowly building up helper functions, and conposing at the end.