;'<<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
-->
### `extend` ###
-> Tests for functionality "Evaluate Robin Expression (with List)"
`extend` evaluates its first two arguments to values of any type, and its
third argument to obtain an alist. It returns a new alist which
associates the first two values in a new pair. The new pair shadows
any existing pairs with the same key that may already be in the alist.
| (extend (literal b) 6 (literal ((a 1) (b 2) (c 3))))
= ((b 6) (a 1) (b 2) (c 3))
The following should be true for any identifier i and alist x.
| (let ((i (literal a))
| (x (literal ((f 5) (g 7)))))
| (lookup i (extend i 1 x)))
= (1)
| (extend (literal b) 6 ())
= ((b 6))
| (extend (literal b) 6 81)
? abort (expected-list 81)
'<<SPEC'
(define extend (fun (id val alist)
(prepend (list id val) alist)))