diff options
Diffstat (limited to 'ipl/progs/longest.icn')
-rw-r--r-- | ipl/progs/longest.icn | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/ipl/progs/longest.icn b/ipl/progs/longest.icn new file mode 100644 index 0000000..444857f --- /dev/null +++ b/ipl/progs/longest.icn @@ -0,0 +1,43 @@ +############################################################################ +# +# File: longest.icn +# +# Subject: Program to write longest line in a file +# +# Author: Ralph E. Griswold +# +# Date: November 25, 1992 +# +############################################################################ +# +# This file is in the public domain. +# +############################################################################ +# +# This program writes the (last) longest line in the input file. If the +# command-line option -# is given, the number of the longest line is +# written first. +# +############################################################################ + +procedure main(argl) + local longest, max, count, countl, number, line + + if argl[1] == "-#" then number := 1 + + count := 0 + max := -1 + + every line := !&input do { + count +:= 1 + if *line >= max then { + max := *line + longest := line + countl := count + } + } + + if \number then write(countl) + write(longest) + +end |