On our third and final day of Factor, we will focus on data structures called tuples, and use them to create a flexible cart checkout application. We’ll see more of Factor’s sweet spot—function composition in the concatenative style—both in the checkout example and in a revisitation of the classic “FizzBuzz” programming quiz. We’ll wrap up the chapter with a few places to look to continue your exploration of Factor.
Factor has an object system, and tuples are classes of objects for storing values into named slots. To define a class, use TUPLE: followed by the class name and the names of the slots:
TUPLE: cart-item name price quantity ; ...