shorten_array

Gamma: Version 4.0
Prev |  | Next

# `shorten_array`

`shorten_array` -- reduces or expands the size of an array.

## Syntax

    shorten_array (array, size)

## Arguments

`array`

  The array to shorten or expand.

`size`

  The new length for the array.

## Returns

The resized array.

## Description

This function reduces or expands the size of an array by cutting off any elements which extend beyond the given size, or by adding nils to the end of the array until the new size is reached. This function is analogous to the C function, `realloc`.

## Example

        Gamma> a = array (1,2,3,4,5);
        [1 2 3 4 5]
        Gamma> shorten_array(a,3);
        [1 2 3]
        Gamma> shorten_array(a,9);
        [1 2 3 nil nil nil nil nil nil]
        Gamma>

## See Also

`array`, `make_array`

Prev | Home | Next
`rplaca`, `rplacd` | Up | `sort`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.