Annotation of 43BSD/contrib/icon/book/18/add2.icn, revision 1.1

1.1     ! root        1: procedure large(s)
        !             2:    local a
        !             3:    a := []
        !             4:    s ? {
        !             5:       &pos := 0        # start at right end
        !             6:       while put(a,integer(move(-segsize)))
        !             7:        # add remaining digits
        !             8:       if &pos ~= 1 then put(a,integer(tab(1)))
        !             9:       }
        !            10:    return a
        !            11: end
        !            12: 
        !            13: procedure add(a1,a2,carry)
        !            14:    local sum
        !            15:    /carry := [0]       # default carry
        !            16:    if *a1 = *a2 = 0 then
        !            17:       return if carry[1] ~= 0 then carry else []
        !            18:    if *a1 > *a2 then a1 :=: a2
        !            19:    if *a1 = 0 then return add(carry,a2)
        !            20:    sum := a1[1] + a2[1] + carry[1]
        !            21:    carry := [sum / base]
        !            22:    return push(add(a1[2:0],a2[2:0],carry),sum % base)
        !            23: end
        !            24: 
        !            25: procedure lstring(a)
        !            26:    local s
        !            27:    s := ""
        !            28:    every s := right(!a,segsize,"0") || s
        !            29:    s ?:= (tab(upto(~'0') | -1) & tab(0))
        !            30:    return s
        !            31: end

unix.superglobalmegacorp.com

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