Annotation of 43BSD/contrib/icon/book/19/fix.icn, revision 1.1

1.1     ! root        1: procedure main()
        !             2:    while write(fix(read()))
        !             3: end
        !             4: 
        !             5: procedure fix(exp)
        !             6:    while exp ?:= 2(="(",tab(bal(')')),pos(-1))
        !             7:    return lassoc(exp,'+-' | '*/') | rassoc(exp,'^') | exp
        !             8: end
        !             9: 
        !            10: procedure lassoc(exp,op)
        !            11:    local j
        !            12:    return exp ? {
        !            13:       every j := bal(op)
        !            14:       form(tab(\j),move(1),tab(0))
        !            15:       }
        !            16: end
        !            17: 
        !            18: procedure rassoc(exp,op)
        !            19:    return exp ? form(tab(bal(op)),move(1),tab(0))
        !            20: end
        !            21: 
        !            22: procedure form(arg1,op,arg2)
        !            23:    return op || "(" || fix(arg1) || "," || fix(arg2) || ")"
        !            24: end

unix.superglobalmegacorp.com

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