Questions tagged [code-translation]

For questions regarding the translation of code from one programming language to another. NOTE that asking to have your code translated is not suitable for Stack Overflow.

Translating code from one programming language to another can be as tricky as translating between natural languages. This is due to the fact that languages implement different sets of features and are often designed with very different goals. What comes as a built-in function in one language may have to be developed from scratch (or at least require a library) to achieve the same functionality in another.

An appropriately formed question might be "How do I translate this statement", or "What are the differences between these two statements in different languages". It is not appropriate to ask for your code to be translated.

388 questions
0
votes
0 answers

Vector subscript out of range in VM Translator?

I've been working on a VM Translator as part of the nand2tetris course and I have spent ages trying to debug this error to no avail. I have tried catching the error but then it throws a debug assertion error: vector subscript out of range. Here is…
cillsley
  • 37
  • 8
0
votes
4 answers

C++ to C# Translator

i found a translator for c++ to c# , but it doesn't work. (Code2Code.net) Test with cout int main(int argc, char** argv) { cout << "Hello World"; return 0; } The Results becomes public static int Main(string [] argv) { cout << "Hello World";…
Translator
0
votes
1 answer

Which tool privides the easiest way to create a textual external DSL for simple code translation?

In my application I have to type in some code for a specific domain and I would like to create a DSL for that. The DSL just should have some really basic commands. DSL code example: srccode{ code: "if(" func: insertInputData(1) code:…
mep
  • 341
  • 2
  • 11
0
votes
0 answers

C to MIPS translation: bubble sort

I'm given the code in C and asked to translate it into MIPS. ##struct Ingredient { ## unsigned ing_type; ## unsigned amount; ##}; ## ##struct Request { ## unsigned length; ## Ingredient ingredients [11]; ##}; ## ##//Performs a bubble sort on the…
user611988
  • 1
  • 1
  • 6
0
votes
1 answer

Rewriting groupby, arrange and mutate with if-else from R to Python

I am trying to rewrite my code from R to Python. I am having a hard time rewriting some of my code involving group_by, arrange and mutate. I have tried transform and apply in Python but have had no success. In R my code looks like the following: S1…
yungpadewon
  • 237
  • 3
  • 10
0
votes
0 answers

Is there a way to reverse-engineer java code?

I am looking for a way to rebuild a compilable java methods from the objects it creates. I know it is trivial in many contexts to build a Java object using a custom data model and go from the POJO to XML/JSON/YAML/etc and then back to a Java…
0
votes
1 answer

How can I translate this .XAML code into C# code

I need some help translating the following .XAML code below to its corresponding C# code:
soulblazer
  • 1,178
  • 7
  • 20
  • 30
0
votes
2 answers

Convert PHP chr()/strval() function to C++

I'm trying to convert a library of character manipulation from PHP to C++. 1) I've used static_cast() to replace all single chr() functions (applied only to a single char, ie: PHP: $out = chr(50); => C++: std::string s =…
Ayak973
  • 468
  • 1
  • 6
  • 23
0
votes
1 answer

checking if a value is greater than another and if not replacing with the smaller value idl to python

Hi so I am working on switching over some code from IDL to python and there's this one function shown here: for i=0l,dim[0]-1 do begin for j=0l,dim[1]-1 do begin y = reform(image[i,j,0:nchannels-1]) > 0 This makes essentially a list…
0
votes
1 answer

Ruby to Scala code translation - Sorting in Scala

I'm converting some code from Ruby to Scala. Problem is that I never programmed Ruby in my life. It's going well, but now I reached a line that I don't know because I'm new in Scala and I don't understand the sorting mechanism. So I want to…
flyist
  • 29
  • 5
0
votes
2 answers

Understanding Python's itertools.chain and next

I'm trying to convert a line of Python code to JavaScript, but I have limited Python knowledge and struggle to make sense of it. Can anyone please try to explain the following line of code? The point_orientation function is not important, it just…
0
votes
2 answers

Multi-language Translation on Web Site

i want to know how did facebook do it, did they add two different html+css or its just css only for changing there theme for different language or is there any special html attribute that changes the direction for complete site? following are two…
Basit
  • 16,316
  • 31
  • 93
  • 154
0
votes
0 answers

Java Code to Haskell (Problems with 2D and 3D arrays)

I have been asked to translate the following code which finds a maximum non-overlapping increasing sub sequence given a large amount of input. I haven't had much time to learn a lot on Haskell and I am stuck how to actually do it. Here is the code…
0
votes
2 answers

Need help translating some Java encryption to PHP

I'm trying to port a "simple" string encryption algorithm from Java to PHP and it uses just enough obscure bits of specific Java libraries that I'm bashing my head against the wall. I'm hoping the SO community can help. Here's the Java: public…
abeger
  • 6,766
  • 7
  • 41
  • 58
0
votes
2 answers

mRNA/DNA to protein

The code that I am trying to produce is about translating a FASTA-file that contains nucleotides (U, T, C, G or A) from DNA or mRNA into amino acids. It went very well, but when I run my program, it reports some mistakes that I don't understand,…
Visintank
  • 1
  • 4