vecs ← seps ##.segs vec                     ⍝ ⍺-separated segments of vector ⍵.

Right argument [vec] is partitioned at items in left argument array  [seps].  In
particular:

- separator items are removed from each result segment.
- adjacent separators in [vec] are treated as if only one had been present.

These effects are illustrated by the following example:

    wds ← ' '∘segs                      ⍝ blank-separated words.

    disp wds 'ready steady      go'     ⍝ three words.
┌→────┬──────┬──┐
│ready│steady│go│
└────→┴─────→┴─→┘

Examples:

    song ← 'Any old Iron, any old iron? Any old, any old, iron?'

    disp '?'segs song
┌→─────────────────────────┬───────────────────────┐
│Any old Iron, any old iron│ Any old, any old, iron│
└─────────────────────────→┴──────────────────────→┘

    disp ','segs¨ '?'segs song
┌→───────────────────────────┬─────────────────────────┐
│┌→───────────┬─────────────┐│┌→───────┬────────┬─────┐│
││Any old Iron│ any old iron│││ Any old│ any old│ iron││
│└───────────→┴────────────→┘│└───────→┴───────→┴────→┘│
└───────────────────────────→┴────────────────────────→┘

    disp ' 'segs¨¨ ','segs¨ '?'segs song
┌→──────────────────────────────┬────────────────────────────┐
│┌→─────────────┬──────────────┐│┌→────────┬─────────┬──────┐│
││┌→──┬───┬────┐│┌→──┬───┬────┐│││┌→──┬───┐│┌→──┬───┐│┌→───┐││
│││Any│old│Iron│││any│old│iron│││││Any│old│││any│old│││iron│││
││└──→┴──→┴───→┘│└──→┴──→┴───→┘│││└──→┴──→┘│└──→┴──→┘│└───→┘││
│└─────────────→┴─────────────→┘│└────────→┴────────→┴─────→┘│
└──────────────────────────────→┴───────────────────────────→┘

See also: words tokens

Back to: contents

Back to: Workspaces

Trouble seeing APL font?