procedure main(A) ll := integer(A[1]) | 72 wordWrap(&input, ll) end procedure wordWrap(f, ll) every (sep := "", s := "", w := words(f)) do if w == "\n" then write(1(.s, s := sep := ""),"\n") else if (*s + *w) >= ll then write(1(.s, s := w, sep := " ")) else (s ||:= .sep||("\n" ~== w), sep := " ") if *s > 0 then write(s) end procedure words(f) static wc initial wc := &cset -- ' \t' # Loose definition of a 'word'... while l := !f do { l ? while tab(upto(wc)) do suspend tab(many(wc))\1 if *trim(l) = 0 then suspend "\n" # Paragraph boundary } end