File: repeat

package info (click to toggle)
epic4 1%3A2.2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,600 kB
  • ctags: 5,377
  • sloc: ansic: 55,723; makefile: 656; sh: 158; perl: 30
file content (103 lines) | stat: -rw-r--r-- 1,882 bytes parent folder | download | duplicates (11)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 * Repeat -- a zillion and one ways to do the classic alias...
 */

/*
 * REPEAT is now a built in command in EPIC3.003 and up.
 * That means you dont need this script any more.
 */

/*
 * Post-modern format:
 * Requires EPIC4-0.9.17 and up
 * Method: Iterative loop
 * Can be called recursively?  Yes. (/for uses local variables)
 */
: alias repeat {
:	for aa from 1 to $0 { $1- }
: }

/*
 * Modern format:
 * Requires: EPIC4pre0 and up
 * Method: word-selection
 * Can be called recursively?  Yes. (/fe uses local variables now)
 */
: alias repeat {
: 	fe ($jot(1 $0)) aa { $1- }
: }

/*
 * Modern format:
 * Requires: EPIC3pre5 and up
 * Method: word-selection
 * Can be called recursively?  Yes. (global variables and push)
 */
: alias repeat {
: 	stack push assign aaa.r
: 	fe ($jot(1 $0)) aaa.r { $1- }
: 	stack pop assign aaa.r
: }


/*
 * Modern format:
 * Requires ircII2.2.9+6 and up.
 * Method: word-selection
 * Can be called recursively?  No. (no local variables in epic yet)
 */
: alias repeat fe ($jot(1 $0)) r.x {$1-}


/*
 * Modern format:
 * Requires ircII2.2.9+5 and up.
 * Method: iterative
 * Can be called recursively?  No.
 */
: alias repeat for (@rx=0,$rx < [$0],@rx++) {$1-}



/*
 * New format:
 * Requires 2.2pre6 and up
 * Method: iterative
 * Can be called recursively?  No.
 */
: alias repeat {
: 	@ rep.cnt = [$0]
: 	while ( rep.cnt > 0 )
: 	{
: 		$1-
: 		@rep.cnt = rep.cnt - 1
: 	}
: 	^assign -rep.cnt
: }


/*
 * New format:
 * Requires 2.2pre6 and up
 * Method: recursion
 * Can be called recursively? Yes.
 */
: alias repeat {
: 	if ([$0] > 0)
: 	{
: 		$1-
: 		repeat ${[$0]-1} $1-
: 	}
: }


/*
 * Old format:
 * Requires 2.2pre5 or older.
 * Method: Iterative
 * Can be called recursively?  No.
 */
: alias repeat ^assign repcnt $0;while "$repcnt>$0" "decrement $1-";^assign -repcnt
: alias decrement $*;^assign repcnt ${$repcnt-1}

#hop'96