| … | … | @@ -86,6 +86,10 @@ ValuePtr ElementOfLink::do_execute(const std::vector<double>& vindex, |
| 86 | 86 | HandleSeq chopped; |
| 87 | 87 | for (double d : vindex) |
| 88 | 88 | chopped.push_back(oset.at((int)(d+0.5))); |
| 89 | |
| 90 | // If user asked for just one thing, hand them that one thing. |
| 91 | if (1 == chopped.size()) |
| 92 | return chopped[0]; |
| 89 | 93 | return createLink(std::move(chopped), vitype); |
| 90 | 94 | } |
| 91 | 95 | |
| … | … | @@ -96,6 +100,16 @@ ValuePtr ElementOfLink::do_execute(const std::vector<double>& vindex, |
| 96 | 100 | std::vector<ValuePtr> chopped; |
| 97 | 101 | for (double d : vindex) |
| 98 | 102 | chopped.push_back(lvec.at((int)(d+0.5))); |
| 103 | |
| 104 | // Special case "hack". This feels both ugly, and natural. |
| 105 | // Ugly, because it breaks with the rhythm below, where |
| 106 | // everything gets wrapped. Natural, because if the user |
| 107 | // asked for just one thing, we should give them ... just |
| 108 | // one thing. Re-wrapping it forces the user to then take |
| 109 | // another step to unwrap it. Anyway, this is an important |
| 110 | // enough design decision, that I write it up, here. |
| 111 | if (1 == chopped.size()) |
| 112 | return chopped[0]; |
| 99 | 113 | return createLinkValue(std::move(chopped)); |
| 100 | 114 | } |
| 101 | 115 | |