/** @file ListOps.hpp * * @author Roland Conybeare, Jan 2026 **/ #pragma once #include "list/IGCObject_DList.hpp" #include "DList.hpp" namespace xo { namespace scm { /** @brief list functions * * note: separate from DList, to avoid problems with deps needed * to compile functions that return obj **/ struct ListOps { using AGCObject = xo::mm::AGCObject; using AAllocator = xo::mm::AAllocator; template static obj nil(); /** shortcut for * cons(mm, cdr, cdr.data()) **/ template static obj cons(obj mm, obj car, obj cdr); /** list with one element @p e1, allocated from @p mm **/ template static obj list(obj mm, obj e1); /** list with two element @p e1, @p e2, allocated from @p mm **/ template static obj list(obj mm, obj e1, obj e2); }; template obj ListOps::nil() { return obj(DList::_nil()); } template obj ListOps::cons(obj mm, obj car, obj cdr) { return obj(DList::_cons(mm, car, cdr.data())); } template obj ListOps::list(obj mm, obj e1) { // clang 15 doesn't like nil() here. return cons(mm, e1, nil()); } template obj ListOps::list(obj mm, obj e1, obj e2) { return cons(mm, e1, list(mm, e2)); } } /*namespace scm*/ } /*namespace xo*/ /* end ListOps.hpp */