Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A new cpp implementation #641

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
all tests passed
yang-le committed Aug 10, 2024
commit ef05f2fe207cb57d3b6f6d12cfdb292366d3a286
13 changes: 5 additions & 8 deletions impls/cc/core.cc
Original file line number Diff line number Diff line change
@@ -286,14 +286,11 @@ std::shared_ptr<MalType> apply(std::vector<std::shared_ptr<MalType>> args)
{
std::vector<std::shared_ptr<MalType>> list;

for (unsigned i = 1; i < args.size(); ++i)
{
if (args[i]->type() == MalType::Type::List)
for (auto item : static_cast<MalList &>(*args[i]))
list.push_back(item);
else
list.push_back(args[i]);
}
for (unsigned i = 1; i < args.size() - 1; ++i)
list.push_back(args[i]);

for (auto item : static_cast<MalList &>(*args[args.size() - 1]))
list.push_back(item);

auto &func = static_cast<MalFunc &>(*args[0]);
return func(list);