summaryrefslogtreecommitdiff
path: root/miralib/ex/selflines.m
blob: cf3d0162ce7d3a9d20b91757b6fbecdfe095d75a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
||this produces an endless self describing scroll of lines, as follows
||	the 1st line is
||	"the 1st line is"
||	the 2nd line is
||	""the 1st line is""
||	the 3rd line is
||	"the 2nd line is"
||	etc...
||To see the result, say
||	output
||Hit control-C (interrupt) when you have seen enough.
||If you would like to send the output to a file, say
||	output &> fil
||where `fil' is the name of the file in which you want to put it
||this will create a background job

output = concat[l++"\n"|l<-selflines]

selflines = mklines 1

mklines n = ("the "++ord n++" line is:"):
	    ("\""++selflines!(n-1)++"\""):
	    mklines(n+1)

ord n = show n++suffix n

suffix 1 = "st"
suffix 2 = "nd"
suffix 3 = "rd"
suffix n = "th", if n=0 \/ 3<=n&n<=9
         = "th", if (n mod 100)div 10 = 1 ||because of 11,12,13
         = suffix(n mod 10), otherwise