ecl-logo Documentation

Middle

Middle[expr]out

returns the middle element of expr.

Details

  • If the Length of 'expr' is even, returns the element immediately to the left of middle.
  • Use Return->Right to return the element immediately right of middle in the case of even length input.
  • Input
    Output
    General Options
    Messages
  • argxMiddle called with `1` arguments; 1 argument is expected.
    middle`1` has a length of zero and no middle element.
    normalNonatomic expression expected at position 1 in `1`

Examples

Basic Examples  (4)

Return the middle element of the list:

If length of list is even, return the element immediately before the middle:

Middle also works with Heads other than List:

Given list of lists, returns a list. Note that Middle is not listable:

Options  (1)

Output  (1)

Use Output option to return element Right of middle when length of input is even:

Messages  (3)

argx  (1)

Too many arguments throws message:

middle  (1)

Empty list throws message:

normal  (1)

Atomic input throws message: