I'm learning Mozart and I have a question, Does anyone knows how to convert a Integer to an Hexadecimal without the manual-mathematical table conversion. Is there any included function/module to do that? I know how to convert the other way:
{String.toInt "0x2d7"} %% Hex to Int
{String.toInt "052"} %% Octal to Int
{String.toInt "0b101010"} %% Binary to Int
Thank you in advance.
I don't think the language has anything like a function or module to convert from decimal to hex. Anyway, here's a possible solution. It may not be very efficient or elegant, but you can see some of the basic ideas the language handles.
Try to run this code in
Mozartby selecting it and after that holding down the Ctrl key, then hitting the dot key and then the R key (to feed region). After this you can feed any of the next lines withCtrl . Ctrl L(to feed line):As you will see the answer is an atom. You can also use the function
{Atom.toString +A ?S}to convert the atom A to the string S. I hope any of this is useful for you.