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
-2
votes
2 answers

C to MIPS translation: decoder

We're given the following code in C and asked to translate it into MIPS. We don't need to handle lo and hi; they're stored for us in $a0 and $a1: void decode_request(unsigned long int request, int* array) { // lo and hi are already stored for us…
Mark T.
  • 29
  • 5
-2
votes
1 answer

Understanding Assembly vs C counterpart

Given this assembly code, I am having trouble translating assembly code into its equivalent C code. int main() { long int x=______; long int mask=0xff; int i,n,m; for(i=0;i<______;i++) { n=i; m=7-i; …
-2
votes
1 answer

Function call stack problem in the code translated from Java into R

I translated Java code into R. I need to check if all lines are translated correctly. Some part most probably is correct because I ran it and R says: Error: C stack usage 7970192 is too close to the limit. I am not sure which part went wrong…
yakochang
  • 1
  • 1
-2
votes
1 answer

Weekday alogorithm conversion from Python into R?

I've written the following function in Python. For any date it works out the correct Week Ending or Commencing date. I can't figure out how to write this in R. Anyone have any ideas? def Week_dates(dt, day, we=False): """ dt is a date …
fred.schwartz
  • 2,023
  • 4
  • 26
  • 53
-2
votes
1 answer

List position of all permutations of characters of a given word, written in 3.6 and breaks in 2.7

I have the following code working in Python 3.6, which returns the position of the given word in a list of all possible permutations of the characters of the word sorted alphabetically. See tests below for example. When submitting this code the test…
Cyber17C
  • 25
  • 2
-2
votes
1 answer

How to convert old-style Fortran DO loop with conditionals to Python?

My question is about converting Fortran to Python language but I couldn't understand the working principle of this part of code. How can I rewrite the code in Python and which statement should I use instead of do if then write statement ? #FOR GEAR…
can23
  • 23
  • 2
-2
votes
2 answers

How to do this the with Jquery instead of javascript

I've been trying to convert this section of script to jQuery instead of vanilla javascript, but I'm not sure how to loop through the elements with jQuery. Basically, I'm grabbing a data attr value from each field to be used as an error message that…
Eckstein
  • 785
  • 9
  • 27
-2
votes
1 answer

Conversion of C++ to Fortran 90

Is there a tool that converts C++ code into fortran? Please state any possible deficiency of the tool you use. I know it sounds silly but I do have a C++ code that calls a big Fortran code inside and I need to to use OpenMP. I am trying to keep the…
Yousef
  • 7
  • 1
  • 2
-2
votes
2 answers

C# code passing void as argument? What's that in Java?

I'm translating a small program from C# to Java. There's 1 line left that I'm wondering about: Thread eventReadingThread = new Thread(() => ReadEvents(url, streamingMode)); ... static void ReadEvents(String serviceURL, bool streamingMode) …
Berit Larsen
  • 739
  • 1
  • 12
  • 29
-2
votes
1 answer

Code translation VB to C# in a Sync Framework 2.1 sample

I followed a walkthrough of a sync framework 2.1 sample and it works fine. But it's written in C# and I want to port it to VB. I came to the following line which I have had a hard time translating: in the static Main of…
Ben Quan
  • 773
  • 11
  • 25
-2
votes
1 answer

IDL WHERE in python?

I am having trouble translating an old IDL script to python- my issue lies in understanding exactly how to interpret IDL's "WHERE" function. Here is my code: FUNCTION noise,day,y N = N_ELEMENTS(y) valid = WHERE(ABS(day[0:N-3]-day[2:N-1]) LT…
-2
votes
3 answers

Does Standard Java translate directly to the Java in Android apps?

For example, I'm using URLConnection and the Thread class in my java program. Can the Android device use URLConnection to connect via a mobile network, and do I have to make any changes to threading to make it usable on the device? Is there anything…
Niko
  • 984
  • 1
  • 7
  • 15
-2
votes
2 answers

Converting c# app into VB

I'm converting a C# app to VB but am uncertain regarding some of the resulting errors. In C# I have- var quotesInvoker = new QuotesInvoker(new[] { "EUR=X", "JPY=X" }); Which converts to - Dim quotesInvoker = New…
Malcom
  • 61
  • 1
  • 9
-2
votes
1 answer

How do I write this in OpenCV with Python?

How do I write the following MATLAB piece of code in Python by using OpenCV ? I have problems with the last line of code, I don't know how to implement that 'single' function. Can you help me ? Thanks. img = imread(''); grayImage =…
drgs
  • 117
  • 1
  • 10
-2
votes
1 answer

Translating from Java to Objective C

I need to translate this from Java to ObjC, problem is I'm not sure exactly what the code in Java is doing (to be specific the portion from int num to the closing } on the if statement below it). I'm not looking for a direct translation, but more of…
1 2 3
25
26