Annotation of researchv10no/cmd/cfront/libstring/test7.c, revision 1.1

1.1     ! root        1: // list test program.  reverses standard input
        !             2: 
        !             3: #include "String.h"
        !             4: #include "list.h"
        !             5: 
        !             6: listdeclare(String)
        !             7: 
        !             8: String_list
        !             9: revrev ( String_list x )
        !            10: {
        !            11:        String_list     ans;
        !            12:        while ( x ) {
        !            13:                String  temp;
        !            14:                x.getX(temp);
        !            15:                String  rtemp;
        !            16:                while ( temp ) {
        !            17:                        char    c;
        !            18:                        temp.getX(c);
        !            19:                        rtemp.unget(c);
        !            20:                }
        !            21:                ans.unget(rtemp);
        !            22:        }
        !            23:        return ans;
        !            24: }
        !            25: 
        !            26: String_list
        !            27: rev ( String_list x )
        !            28: {
        !            29:        String_list     ans;
        !            30:        while ( x ) {
        !            31:                String  temp;
        !            32:                x.getX(temp);
        !            33:                ans.unget(temp);
        !            34:        }
        !            35:        return ans;
        !            36: }
        !            37: 
        !            38: String_list
        !            39: revrec ( String_list x )
        !            40: {
        !            41:        if ( x ) {
        !            42:                String  temp;
        !            43:                x.getX(temp);
        !            44:                return revrec(x).put(temp);
        !            45:        } else return x;
        !            46: }
        !            47: 
        !            48: main()
        !            49: {
        !            50:        String_list     slist;
        !            51:        String  temp;
        !            52:        while ( cin >> temp)
        !            53:                slist.put(temp);
        !            54:        cout << "rev(slist):"  << rev(slist) << "\n";
        !            55:        cout << "revrec(slist):" << revrec(slist) << "\n";
        !            56:        cout << "revrev(slist):" << revrev(slist) << "\n";
        !            57: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.