Convert All List Elements (or individual variables) to Strings


  • TA School

    Very simple procedure, but useful fo' outputtin' all them variables to TA in a format where it won't kill all numbers. Sure I'm not the first to do this but thought I'd share for anyone who hadn;t thought to.

    (No more will you have to write : [convert(a,string), convert(b,string), convert(c,string)...etc.] )

    str := proc(x)
        local i,rtn := []:
        if type(x,list) then
            for i to numelems(x) do rtn:=[op(rtn),str(x[i])] od:
        else rtn:=convert(x,string): fi:
        return rtn:
    end proc:
    simply add at end of your final line of maple call:
    $m=maple("
    str := proc(x)
        local i,rtn := []:
        if type(x,list) then
            for i to numelems(x) do rtn:=[op(rtn),str(x[i])] od:
        else rtn:=convert(x,string): fi:
        return rtn:
    end proc: ... ... str([a,b,c...etc.]) ");

Log in to reply