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

Tree @master (Download .tar.gz)

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

### `add` ###

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

`add` evaluates both of its arguments to numbers and evaluates to the sum
of those two numbers.

    | (add 14 23)
    = 37

`add` expects exactly two arguments.

    | (add 14)
    ? abort (illegal-arguments

    | (add 6 7 7)
    ? abort (illegal-arguments

Both of the arguments to `add` must be numbers.

    | (add 14 #t)
    ? abort (expected-number #t)

    | (add #t 51)
    ? abort (expected-number #t)

'<<SPEC'

(define add (fun (a b)
  (subtract a (subtract 0 b))))