[M3devel] STL algorithms? sort/unique?

Daniel Alejandro Benavides D. dabenavidesd at yahoo.es
Fri Sep 28 18:07:31 CEST 2012


Hi all:
so what's the matter on writing GENERIC MODULE List:
http://modula3.elegosoft.com/cm3/doc/help/gen_html/libm3/src/list/List.mg.html

What are vectors, object arrays in C++? What is the difference between an array and a vector? More operations, it seems, I guess you don't need a vector for that (and why for just an int)?
 List module is a dynamic structure of Objects, RT errors are caught in ESC so it's clear how and when to use it, hopefully.
Thanks in advance


--- El vie, 28/9/12, Jay K <jay.krell at cornell.edu> escribió:

De: Jay K <jay.krell at cornell.edu>
Asunto: [M3devel] STL algorithms? sort/unique?
Para: "m3devel" <m3devel at elegosoft.com>
Fecha: viernes, 28 de septiembre, 2012 02:18



    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/dafd7ddb/attachment-0002.html>


More information about the M3devel mailing list