Text this: Classification of fine-grained igneous, sedimentary and metamorphic rocks through structured programming