| 48 | } |
| 49 | |
| 50 | adt::Result<Val> Join(const Self& self, const std::vector<Val>& args) { |
| 51 | ADT_CHECK(args.size() == 1) << adt::errors::TypeError{ |
| 52 | std::string() + "join() takes 1 argument but " + |
| 53 | std::to_string(args.size()) + " were given."}; |
| 54 | ADT_LET_CONST_REF(lst, args.at(0).template TryGet<adt::List<Val>>()) |
| 55 | << adt::errors::TypeError{ |
| 56 | std::string() + |
| 57 | "the argument 1 of join() should be 'list' not '" + |
| 58 | axpr::GetTypeName(args.at(0)) + "'."}; |
| 59 | std::ostringstream ss; |
| 60 | int i = 0; |
| 61 | for (const auto& elt : *lst) { |
| 62 | ADT_LET_CONST_REF(item, elt.template TryGet<std::string>()) |
| 63 | << adt::errors::TypeError{std::string() + "sequence item " + |
| 64 | std::to_string(i) + |
| 65 | ": expected str instance, " + |
| 66 | axpr::GetTypeName(elt) + " found"}; |
| 67 | if (i++ > 0) { |
| 68 | ss << self; |
| 69 | } |
| 70 | ss << item; |
| 71 | } |
| 72 | return ss.str(); |
| 73 | } |
| 74 | |
| 75 | static adt::Result<Val> StaticReplace(const Val& self_val, |
| 76 | const std::vector<Val>& args) { |
nothing calls this directly
no test coverage detected