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

Tree @master (Download .tar.gz)

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

### `append` ###

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

`append` evaluates both of its arguments to lists.  It then
evaluates to a list which is the concatenation of these lists.

    |   (append (list 1 2 3) (list 4 5 6))
    = (1 2 3 4 5 6)

    |   (append () ())
    = ()

'<<SPEC'

(define append (fun (li new-tail)
  (bind append-r (fun (self li new-tail)
    (if (empty? li)
      new-tail
      (prepend (head li) (self self (tail li) new-tail))))
  (append-r append-r li new-tail))))