예제 #1
0
 Element InterpretContainer_( Container container
                            , Environment&  environment
                            , std::vector<Element> const& elements)
 {
     Container newContainer = container.Copy();
     if (  1 == elements.size() )
     {
        if (  Types::FUNCTION == elements[0].Type()
           || Types::BUILTIN == elements[0].Type() )
        {
            try
            {
                SortContainer_(newContainer, environment, elements[0]);
            }
            catch(BadFunctorResult const& result)
            {
                std::stringstream ss;
                ss << "functors should return true/false values, received "
                   << result.badResult.ToString();
                return Error(ss.str());
            }
        }
        else
        {
            std::stringstream ss;
            ss << "sort requires a function/builtin parameter, received a " 
               << elements[0].ToString();  
            return Error(ss.str());
        }
     }    
     return newContainer;
 }
예제 #2
0
        Element InterpretContainer_( Container container
                                   , Environment&
                                   , std::vector<Element> const& elements)
        {
            Container newContainer = container.Copy();
            
            size_t const SIZE = elements.size();
            for(size_t i=0; i<SIZE; ++i)
            {
                newContainer.Add(elements[i]);
            } 

            return newContainer;
        }
예제 #3
0
        Element InterpretContainer_( Container container
                                   , Environment& 
                                   , std::vector<Element> const& elements)
        {
            Container newContainer = container.Copy();
            
            size_t const SIZE = elements.size();
            for(size_t i=0; i<SIZE; ++i)
            {
                Element element(elements[i]);
                newContainer.Insert(element, static_cast<int>(i));
            } 

            return newContainer;
        }