-- smart.e global function smart_sprint(object o) sequence s if atom(o) then return sprintf("%g", {o}) elsif length(o) = 0 then return "{}" elsif equal(repeat(1,length(o)), o > 0 and o <= 255) then return "\"" & o & "\"" else s = "{ " s &= smart_sprint(o[1]) for i = 2 to length(o) do s &= ", " & smart_sprint(o[i]) end for return s & " }" end if end function global procedure smart_print(object o) puts(1, smart_sprint(o) & "\n") end procedure global function sizeof(object o) integer sum if integer(o) then return 4 elsif atom(o) then return 4+8 end if sum = 4+20 for i = 1 to length(o) do if integer(o[i]) then sum += 4 elsif atom(o[i]) then sum += 4+8 else sum += sizeof(o[i]) end if end for return sum end function include graphics.e global procedure smart_sprintc(object o) if atom(o) then text_color(9) printf(1, "%g", {o}) elsif length(o) = 0 then text_color(7) puts(1,"{}") elsif equal(repeat(1,length(o)), o > 0 and o <= 255) then text_color(11) puts(1, "\"") puts(1, o) puts(1, "\"") else text_color(7) puts(1, "{ ") smart_sprintc(o[1]) for i = 2 to length(o) do text_color(7) puts(1, ", ") smart_sprintc(o[i]) end for text_color(7) puts(1, " }") end if end procedure global procedure smart_printc(object o) smart_sprintc(o) text_color(7) puts(1, "\n") end procedure wrap(1)