[top][index]
search for:

lines -- split a string into lines

lines s -- yields an array of strings obtained from the string s by breaking it at newline or return characters.
lines(nl,s) -- yields an array of strings obtained from the string s by breaking it at the newline characters specified by the string nl.

The form lines s is designed to break lines correctly when the file follows the Unix, MS-DOS, or Macintosh convention and contains no extraneous isolated newline or return characters. In other words, it will break a line at "\r\n", "\n", or "\r".

The string nl should be a string of length 1 or 2.

See also:

  • newline
  • Ways to use lines :

  • lines String
  • lines(String,String)
  • Code:

         -- ../../../Macaulay2/m2/methods.m2:278-280
         lines = x -> (
              l := separate x;
              if l#-1 === "" then drop(l,-1) else l)

    [top][index]
    search for: