November 2014
Intermediate to advanced
320 pages
7h 8m
English
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:
| factor/examples/tuples/tuples.factor | |
| | USE: kernel |
| | |
| | IN: examples.tuples |
| | |
* | TUPLE: cart-item name price quantity ; ... |
Read now
Unlock full access