digital literacy for everyone
[lit][generate-title]
[lit]
a group is one or more lines of text that are not separated by lines of whitespace only:
group one
this is group one
still group one
this is group two
group three
group three also
groupsortlen will find groups in text, and sort incoming text by the number of lines in each group:
this is group two
group three
group three also
group one
this is group one
still group one
[fig]
# 2019 mn
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
proginf "groupsortlen 0.1, mar 2019 mn"
p arrstdin
trimlen 0
grouplen 0
topgrouplen 0
forin each p
trimlen each rtrim len
ifmore trimlen 0
now grouplen plus 1 swap now grouplen
fig
ifmore grouplen topgrouplen
topgrouplen grouplen
fig
ifequal trimlen 0
grouplen 0
fig
next
grouplen 0
for group 1 topgrouplen 1
buf arr mid 1 0
forin each p
trimlen each rtrim len
ifmore trimlen 0
now grouplen plus 1 swap now grouplen
buf plus each
fig
ifequal trimlen 0
ifequal grouplen group
forin groupeach buf
now groupeach print
next
now "" print
fig
buf "" arr mid 1 0
grouplen 0
fig
next
next
fig main page: [url]https://freesoftwareresistance.neocities.org/fig/index.html[url]
home: [lit]https://freesoftwareresistance.neocities.org[lit]