repl.txt (973B)
1 2 {{alias}}( idx, max, mode ) 3 Returns an index given an index mode. 4 5 Parameters 6 ---------- 7 idx: integer 8 Index. 9 10 max: integer 11 Maximum index value. 12 13 mode: string 14 Specifies how to handle an index outside the interval [0,max]. If equal 15 to 'throw', the function throws an error. If equal to 'wrap', the 16 function wraps around an index using modulo arithmetic. If equal to 17 'clamp', the function sets an index to either `0` (minimum index) or the 18 maximum index. 19 20 Returns 21 ------- 22 out: integer 23 Index. 24 25 Examples 26 -------- 27 > var idx = {{alias}}( 2, 10, 'throw' ) 28 2 29 > idx = {{alias}}( 2, 10, 'wrap' ) 30 2 31 > idx = {{alias}}( -4, 10, 'wrap' ) 32 7 33 > idx = {{alias}}( 13, 10, 'wrap' ) 34 2 35 > idx = {{alias}}( 2, 10, 'clamp' ) 36 2 37 > idx = {{alias}}( -4, 10, 'clamp' ) 38 0 39 > idx = {{alias}}( 13, 10, 'clamp' ) 40 10 41 42 See Also 43 -------- 44