JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.54k stars 5.47k forks source link

Unparse / homoiconic representation #2739

Closed mschauer closed 11 years ago

mschauer commented 11 years ago

(Feature) A function which converts a range of objects, for example matrices, vectors or a lists into a string which is readable by the Julia parser and represents the same object would be helpful. I would expect a function called "repr" do this, but repr is using "show" to create a string.

julia> A = [1 2; 3 4]
2x2 Int32 Array:
1  2
3  4

julia>arep = representation(A)
"[1 2; 3 4]"

julia> A == eval(parse(arep))
true
JeffBezanson commented 11 years ago

dup of #2017