-
-
Notifications
You must be signed in to change notification settings - Fork 806
/
Copy pathrepl.txt
84 lines (69 loc) · 2.11 KB
/
repl.txt
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
{{alias}}( idx, max, mode )
Returns an index given an index mode.
Parameters
----------
idx: integer
Index.
max: integer
Maximum index value.
mode: string
Specifies how to handle an index outside the interval [0, max]. If equal
to 'throw', the function throws an error. If equal to 'normalize', the
function throws an error if provided an out-of-bounds normalized index.
If equal to 'wrap', the function wraps around an index using modulo
arithmetic. If equal to 'clamp', the function sets an index to either 0
(minimum index) or the maximum index.
Returns
-------
out: integer
Index.
Examples
--------
> var idx = {{alias}}( 2, 10, 'throw' )
2
> idx = {{alias}}( 2, 10, 'wrap' )
2
> idx = {{alias}}( -4, 10, 'wrap' )
7
> idx = {{alias}}( 13, 10, 'wrap' )
2
> idx = {{alias}}( 2, 10, 'clamp' )
2
> idx = {{alias}}( -4, 10, 'clamp' )
0
> idx = {{alias}}( 13, 10, 'clamp' )
10
> idx = {{alias}}( 2, 10, 'normalize' )
2
> idx = {{alias}}( -4, 10, 'normalize' )
7
{{alias}}.factory( mode )
Returns a function for returning an index according to a provided index
mode.
The function returns a function which accepts the following arguments:
- idx: index.
- max: maximum index value.
Parameters
----------
mode: string
Specifies how to handle an index outside the interval [0, max]. If equal
to 'throw', the function throws an error. If equal to 'normalize', the
function throws an error if provided an out-of-bounds normalized index.
If equal to 'wrap', the function wraps around an index using modulo
arithmetic. If equal to 'clamp', the function sets an index to either 0
(minimum index) or the maximum index.
Returns
-------
fcn: Function
Function for returning an index.
Examples
--------
> var f = {{alias}}.factory( 'clamp' );
> var idx = f( 2, 10 )
2
> idx = f( -4, 10 )
0
> idx = f( 13, 10 )
10
See Also
--------