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

Tree @master (Download .tar.gz)

sign.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
-->

### `sign` ###

    -> Tests for functionality "Evaluate Robin Expression (with literal)"

`sign` evaluates its sole argument to a number, then
evaluates to 0 if that number is 0, 1 if that number is positive, or
-1 if that number is negative.

    | (sign 26)
    = 1

    | (sign 0)
    = 0

    | (sign (subtract 0 200))
    = -1

`sign` expects a number.

    | (sign #f)
    ? abort (expected-number #f)

    | (sign (literal k))
    ? abort (expected-number k)

`sign` expects exactly one argument.

    | (sign 100 200 300)
    ? abort (illegal-arguments (100 200 300))

    | (sign)
    ? abort (illegal-arguments ())

'<<SPEC'

(require sign)