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

Tree @master (Download .tar.gz)

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

### `or` ###

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

`or` evaluates both of its arguments to booleans, and evaluates to the
logical disjunction (boolean "or") of these two values.

    | (or #t #t)
    = #t

    | (or #t #f)
    = #t

    | (or #f #t)
    = #t

    | (or #f #f)
    = #f

`or` expects exactly two arguments.

    | (or #f)
    ? abort

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

`or` expects both of its arguments to be booleans.

    | (or 100 #f)
    ? abort (expected-boolean 100)

    | (or #f 99)
    ? abort (expected-boolean 99)

`or` is short-circuiting in the sense that no arguments after the first
`#t` argument will be evaluated.  Fully testing this requires side-effects,
but it can be demonstrated as follows.

    | (or #t 100)
    = #t

'<<SPEC'

(define or (fun (a b)
  (if a #t (if b #t #f))))