git @ Cat's Eye Technologies Robin / master stdlib / prepend.robin
master

Tree @master (Download .tar.gz)

prepend.robin @masterraw · history · blame

;'<<SPEC'

<!--
Copyright (c) 2012-2024, Chris Pressey, Cat's Eye Technologies.
This file is distributed under a 2-clause BSD license.  See LICENSES/ dir.
SPDX-License-Identifier: LicenseRef-BSD-2-Clause-X-Robin
-->

### `prepend` ###

    -> Tests for functionality "Evaluate core Robin Expression"

`prepend` evaluates both of its arguments, then evaluates to a list cell
which contains the first value as its data and the second value as the
continuation of the list.

    | (prepend () ())
    = (())

    | (prepend #t (prepend #f ()))
    = (#t #f)

The second argument to `prepend` must be a list.

    | (prepend #t #f)
    ? abort (expected-list #f)

The first argument to `prepend` can be any type, but fewer than or more than
two arguments will produce an abort value.

    | (prepend #t)
    ? abort (illegal-arguments (#t))

    | (prepend #f #t #f)
    ? abort (illegal-arguments (#f #t #f))

Attempting to prepend an `abort` value to a list will produce an
`abort` value.

    | (prepend (abort 999) (prepend #f ()))
    ? abort 999

    | (prepend #t (abort 999))
    ? abort 999

`prepend` is basically equivalent to Scheme's `cons`, except for the
requirement that the second argument be a list.

'<<SPEC'

(require prepend)