git @ Cat's Eye Technologies Robin / master stdlib / equal-p.robin
master

Tree @master (Download .tar.gz)

equal-p.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
-->

### `equal?` ###

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

`equal?` evaluates both of its arguments to arbitrary S-expressions
and compares them for deep equality.

`equal?` works on symbols.

    | (equal?
    |   (literal this-symbol)
    |   (literal this-symbol))
    = #t

    | (equal?
    |   (literal this-symbol)
    |   (literal that-symbol))
    = #f

`equal?` works on lists.

    | (equal? (prepend 1 (prepend 2 (prepend 3 ())))
    |         (prepend 1 (prepend 2 (prepend 3 ()))))
    = #t

`equal?` works on lists, deeply.

    | (equal? (prepend 1 (prepend 2 (prepend 7 ())))
    |         (prepend 1 (prepend 2 (prepend 3 ()))))
    = #f

Two values of different types are never equal.

    | (equal? #t (prepend (literal a) ()))
    = #f

    | (equal? #f ())
    = #f

Arguments to `equal?` can be any type, but fewer than or more than
two arguments will produce an abort value.

    | (equal? 7)
    ? abort (illegal-arguments (7))

    | (equal? 7 8 9)
    ? abort (illegal-arguments (7 8 9))

'<<SPEC'

(require equal?)