File: repeat

package info (click to toggle)
epic 3.004-17.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,192 kB
  • ctags: 3,197
  • sloc: ansic: 40,843; makefile: 530; sh: 129; perl: 17
file content (83 lines) | stat: -rw-r--r-- 1,392 bytes parent folder | download | duplicates (4)
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
/*
 * 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.
 */

/*
 * Modern format:
 * Requires: EPIC3pre5 and up
 * Method: word-selection
 * Can be called recursively?  Yes.
 */
: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.
 */
: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