[M3devel] STL algorithms? sort/unique?

Jay K jay.krell at cornell.edu
Fri Sep 28 09:18:19 CEST 2012


    I have an IntSeq.T with a bunch of integers.    
    What is a good terse efficient idiom for sort and unique?    

    In C++ I would say:        vector<int> a;        a.push_back(...);        a.push_back(...);        std::sort(a.begin(), a.end());        a.resize(std::unique(a.begin(), a.end()) - a.begin());        for (auto i = a.begin(); i != a.end(); ++i)    {
      do stuff with *i    } 
    Nice, terse, efficient.        In Modula-3?    

I know that unique is one of the easiest algorithms to manually write inline,but I shouldn't have to.

(I'm really trying to stay in Modula-3 here, but it is definitely a struggle. :( )

Thank you, - Jay

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120928/a782dffa/attachment-0001.html>


More information about the M3devel mailing list