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

MIPS function calling and stack pointer. Program not returning to main function

My task was to translate the following c code to MIPS assembly. int compare(int a, int b) { if ( add(b, a) >= 100) return a; else return b; } int add(int x, int y){ return (x+y); } This is what I managed to write but somehow it does…
tessa
  • 1
0
votes
1 answer

How to save babeljs formatting for gulp task?

I am using gulp and I want to save formatting of my .js files with babeljs task, how can I perform this? e.g. I have: var PC1 = 'Customer', PC2 = 'Purchase Frequency', PC3 = 'Purchase Value', PC4 = 'Most Viewed Category', PC5 =…
0
votes
2 answers

Correctly Translate .Take(1)(0) to C# to fix Cannot apply indexing with [] error?

I have a bit of VB code that needs to be translated into C#: Private myState As Object = Me ''' ''' Fill out the properties of this class by deserializing the given XML into an object of the same type as this class and then…
Carl Onager
  • 4,112
  • 2
  • 38
  • 66
0
votes
2 answers

CType function in C#

Below is code from VB.NET script to set DataSource in RS.exe script file. Could you please help me to convert it into C#? The whole code is as below. Dim dataSources(0) As DataSource Dim dsr0 As New DataSourceReference dsr0.Reference = "/Aroh/Data…
0
votes
2 answers

Automatic translation from fortran 90 to f77

Is there an converter from fortran 90 downto fortran 77 ? I have a fortran77 only compiler and want to run NAS Parallel Benchmark (NPB for short) on it. But NPB uses some features of F90, like do enddo, smth else. All features are rather simple. Is…
osgx
  • 90,338
  • 53
  • 357
  • 513
0
votes
2 answers

What is the C++ equivalent code of this Python slicing statement?

I am trying to translate the following Python statements to C++: some_array = [11, 22, 33, 44] first, rest = some_array[0], some_array[1:] What I have so far is this: int array[4] = {11, 22, 33, 44}; vector some_array (array, 4); int first =…
lifebalance
  • 1,846
  • 3
  • 25
  • 57
0
votes
6 answers

Difficulties of transforming a Java program to another language (or vice versa)

Is there anything simple Java can't do that can be done in a similar language or vice versa? Lets say you have a piece of software in language X and you rewrite it entirely to Java (or the other way around), what are the little things that would…
NomeN
  • 17,140
  • 7
  • 32
  • 33
0
votes
1 answer

What is the equivalent of the C# Convert.ToInt32 in Java

I am trying to translate some C# code into java and would like to know what is the java equivalent of System.Convert.ToInt32(char): Converts the value of the specified Unicode character to the equivalent 32-bit signed…
DD.
  • 21,498
  • 52
  • 157
  • 246
0
votes
1 answer

Javascript to jQuery translation

I have just started studying jquery and javascript and have encountered a line of code that I dont know how to translate. Any help would be much appreciated. Id like to translate it from JavaScript to jQuery so that I can use classes. Here are the…
Fyxerz
  • 169
  • 1
  • 14
0
votes
2 answers

Translating Ruby. How do I do this in Python?

I want to find a particular element in a list like this: my_list.find { |e| e == 'find this' } I know in Python I can do: [e for e in my_list if e == 'find this'] But this returns a list as opposed to the element I want. I know how I can do this…
Paul Mouzas
  • 53
  • 1
  • 4
0
votes
1 answer

Antlr 4 - Java grammar rule "Explicit Generic Invocation" never gets visited

I was building a listener to translate all java method calls A.Foo(args) to A.Bar(args). It appeared to me that the rule: expression '.' explicitGenericInvocation Is the most fitting rule to listen to. However, after visual inspection of the tree,…
314314314
  • 249
  • 1
  • 10
0
votes
0 answers

How can I use flex or awk to automate translation of code from one programming language to another?

It should be noted that the structure of code of the two programming languages is different, as in, the way certain IF-ELSE statements are written is different and I need to scan through the first code completely to know variables to be declared in…
0
votes
0 answers

Simple (but not for me) - Translate ActionScript 3 to C# code

recently I have discovered C#, which is really what I want. Before C# I was coding with AS3. I've recoded all my old program using C# but I am blocked with this : public function Envoie_Serveur(param1:String) : void { var _loc_2:* =…
Knoweldges
  • 72
  • 8
0
votes
1 answer

Gstreamer Editing Services. Playing real video file. GESAsset element (translation from Python to C)

I'm trying to play video file using GES. I found python bindings example cut parts of a video using gstreamer/Python (gnonlin?) and I want to translate it to C language. This is the excerpt of the python code which I want to translate to C: asset =…
Benas
  • 2,106
  • 2
  • 39
  • 66
0
votes
0 answers

Are these C# and Python code snippets functionally identical?

So I have a bit of Python source code that I want to recreate in C#. The code is about reading and decrypting a binary file. I have tested the function on an existing file and it runs without errors; while the resulting string is not garbled or…
Hackworth
  • 1,069
  • 2
  • 9
  • 23