❄️ SNOBOL HEX DIFFICULTY: Adept Behavioral

The Iterator of Snobol

Walking the hidden paths of a string element by element.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Iterator
ARCANUM SCHOOL: Divination // Seeking
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SNOBOL PATTERN //
        * Iterator Pattern in SNOBOL4
        SPELL_COMPONENTS = 'Eye_of_Newt,Toe_of_Frog,Wool_of_Bat,'

NEXT_ITEM
        SPELL_COMPONENTS BREAK(',') . ITEM ',' = '' :F(DONE)
        OUTPUT = 'Adding component: ' ITEM
        :(NEXT_ITEM)
DONE
        OUTPUT = 'Potion complete.'
END

To iterate through a collection in SNOBOL, one often repeatedly destroys the collection using pattern replacement. BREAK consumes the string until a delimiter is found, yielding the current item and advancing the cursor magically.

Runic Tags: #snobol #behavioral #iterator