Standard Library/text

From J Wiki
Jump to navigation Jump to search
Overview | android | break | colib | compare | coutil | dates | debug | dir | dll | files | jade | jal | stdlib | strings | sysenv | text | unxlib

This script defines text utilities and is included in the J standard library. Definitions are loaded into the z locale.

Definitions

C cutpara
F foldpara, foldtext
T topara

cutpara (verb)

Cut text into boxed list of paragraphs.

Syntax:

cutpara text

Example:

   cutpara 'one',LF,'two',LF2,'three'
┌────────┬─────┐
│one two │three│
└────────┴─────┘

foldpara (verb)

Fold string of text with no LF.

See also foldtext which calls this utility on each paragraph.

Syntax:

width foldpara data

foldtext (verb)

Fold text to given width.

Syntax:

width foldtext text

Example:

   A=: 'In the very middle of the court was a table, with a large dish of tarts upon it.'

   30 foldtext A
In the very middle of the
court was a table, with a
large dish of tarts upon it.

topara (verb)

Convert text to paragraphs.

Syntax:

topara text

Replaces single LFs not followed by blanks by spaces, except for LF's at the beginning

Example:

   topara 'one',LF,'two',LF2,'three'
one two

three