Macaulay2 » Documentation
Packages » Macaulay2Doc > The Macaulay2 language > strings and nets > lines
next | previous | forward | backward | up | index | toc

lines -- split a string into lines

Synopsis

Description

The form lines s is designed to break lines correctly when the file follows the Unix or MS-DOS convention. In other words, it will break a line at \r\n or \n.

i1 : lines "a\nb\nc\n"

o1 = {a, b, c}

o1 : List
i2 : peek oo

o2 = {"a", "b", "c"}
i3 : lines "a\nb\nc\nd"

o3 = {a, b, c, d}

o3 : List
i4 : peek oo

o4 = {"a", "b", "c", "d"}
i5 : lines( "\\.", "a.b.c." )

o5 = {a, b, c}

o5 : List
i6 : peek oo

o6 = {"a", "b", "c"}
i7 : lines( "\\.", "a.b.c.d" )

o7 = {a, b, c, d}

o7 : List
i8 : peek oo

o8 = {"a", "b", "c", "d"}

Caveat

For backwards compatibility, if the pattern is a single character and it is an unescaped special character, such as +, *, or ., then it is treated as a literal character. In future code, the pattern must be escaped.

See also

Ways to use lines:

For the programmer

The object lines is a function closure.