part#

A function that can be used in Formulas.

## Syntax and semantics

`part#` (`vector#`, `from`, `to`)
  compute a subsequence of elements of a vector.

## Examples

`assert part# ({ 7, 4, 99, 103, 1 }, 3, 4) = { 99, 103 }
`

## Examples of error messages

Checks on the number of arguments (always has to be 3):

`asserterror The function “part#” requires exactly three arguments
` `... (namely a vector, a starting index, and an end index),
` `... not the 0 given.
` `a# = part# ()
` `
` `asserterror The function “part#” requires exactly three arguments
` `... (namely a vector, a starting index, and an end index),
` `... not the 5 given.
` `a# = part# (7, 8, 9, "hello", "world")
`

Checks on the types of the arguments (always has to be vector, number, number):

`asserterror The first argument of the function “part#” should be
` `... a numeric vector, not a number.
` `a# = part# (2, 4, { 5, 6, 7, 9, 8 })
` `
` `asserterror The first argument of the function “part#” should be
` `... a numeric vector, not a string.
` `a# = part# ("hello", 4, { 5, 6, 7, 9, 8 })
` `
` `asserterror The second argument of the function “part#” should be
` `... a number (the starting index), not a string.
` `a# = part# ({ 5, 6, 7, 9, 8 }, "hello", 4)
` `
` `asserterror The second argument of the function “part#” should be
` `... a number (the starting index), not a numeric vector.
` `a# = part# ({ 5, 6, 7, 9, 8 }, { 0 }, 4)
` `
` `asserterror The third argument of the function “part#” should be
` `... a number (the end index), not a string.
` `a# = part# ({ 5, 6, 7, 9, 8 }, 4, "hello")
` `
` `asserterror The third argument of the function “part#” should be
` `... a number (the end index), not a numeric vector.
` `a# = part# ({ 5, 6, 7, 9, 8 }, 4, { 0 })
`

Finally the checks on the preconditions of the arguments: both element numbers should be within bounds:

`asserterror The second argument of the function “part#” (the starting index)
` `... should (after rounding) be a positive whole number, not -3.
` `a# = part# ({ 5, 6, 7, 9, 8 }, -2.98, 0)
` `
` `asserterror The second argument of the function “part#” (the starting index)
` `... should (after rounding) be a positive whole number, not 0.
` `a# = part# ({ 5, 6, 7, 9, 8 }, 0, 0)
` `
` `asserterror The second argument of the function “part#” (the starting index)
` `... should (after rounding) be at most the number of elements (5), not 99.
` `a# = part# ({ 10, 6, 7, 9, 8 }, 99, 0)
` `
` `asserterror The second argument of the function “part#” (the starting index)
` `... should (after rounding) be at most the number of elements (5), not 6.
` `a# = part# ({ 10, 6, 7, 9, 8 }, 5.5, 0)
` `
` `asserterror The third argument of the function “part#” (the end index)
` `... should (after rounding) be a positive whole number, not -3.
` `a# = part# ({ 10, 6, 7, 9, 8 }, 3, -2.98)
` `
` `asserterror The third argument of the function “part#” (the end index)
` `... should (after rounding) be a positive whole number, not 0.
` `a# = part# ({ 10, 6, 7, 9, 8 }, 3, 0)
` `
` `asserterror The third argument of the function “part#” (the end index)
` `... should (after rounding) be at most the number of elements (5), not 99.
` `a# = part# ({ 10, 6, 7, 9, 8 }, 3, 99)
` `
` `asserterror The third argument of the function “part#” (the end index)
` `... should (after rounding) be at most the number of elements (5), not 6.
` `a# = part# ({ 10, 6, 7, 9, 8 }, 3, 5.5)
`

### Links to this page

- What was new in 6.4?