// Part of the Carbon Language project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #ifndef EXECUTABLE_SEMANTICS_INTERPRETER_CONS_LIST_H_ #define EXECUTABLE_SEMANTICS_INTERPRETER_CONS_LIST_H_ namespace Carbon { template struct Cons { Cons(T e, Cons* n) : curr(e), next(n) {} T curr; Cons* next; }; template auto MakeCons(const T& x) -> Cons* { return new Cons(x, nullptr); } template auto MakeCons(const T& x, Cons* ls) -> Cons* { return new Cons(x, ls); } template auto Length(Cons* ls) -> unsigned int { if (ls) { return 1 + Length(ls->next); } else { return 0; } } } // namespace Carbon #endif // EXECUTABLE_SEMANTICS_INTERPRETER_CONS_LIST_H_