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
1 answer

Circular reference of templates in C++

Consider something like this in C#: class C {} class D : C {} class E : C {} Is an equivalent construction possible in C++ using templates?
markonius
  • 625
  • 6
  • 25
0
votes
2 answers

How do I write the init function from Haskell in Prolog

init :: [a] -> [a] init [_] = [] init (x:xs) = x : init xs Formulate the appropriate Prolog rule init(Xs,Ys) which is true if (and only if) Ys is the initial part of Xs. That is, the query init([1,2,3,4,5],[1,2,3,4]). would evaluate to true, or…
0
votes
0 answers

Translate Python export_text decision rules to SAS IF THEN DO; END code

I am attempting to translate Python's sklearn.tree export_text output into SAS conditions. There has been a solution given in Python for this problem here (at the very end of the page) : How to extract the decision rules from scikit-learn…
0
votes
0 answers

Convert C# unsafe code to its VB.NET equivalent

Given the limitations of VB.NET, how do I get the VB code to successfully function as closely as possible to this C# code?: // ImageData -> Bitmap (unsafe) public static unsafe Bitmap ToBitmap(this ImageData bitmap) { fixed(byte* = bitmap.Data) …
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
0
votes
1 answer

Translation of some Classic ASP (vbScript) into PHP

I'm trying to translate a block of Classic ASP (vbScript) into PHP. I've made an honest attempt, but my translation doesn't appear to be correct. Could anybody help me out? First, the vbScript Code: szTemp =…
Annatar
  • 382
  • 1
  • 4
  • 12
0
votes
1 answer

Translate Fortran binary output to Visual Basic .NET

We have a small Fortran program based on the Intel compiler that outputs binary data. I am trying to refactor that code to .NET. I researched how the binary writing in Fortran works but am a bit lost. Using the same input we do not get same binary…
sinDizzy
  • 1,300
  • 7
  • 28
  • 60
0
votes
0 answers

Translate C# to VB.Net for a Salesforce REST call example

I am trying to call a REST service on Salesforce. I found a great example with C#, and I am attempting to translate it to VB.Net. So far I did well translating, but one line is giving me trouble. Please help with the translation of this line of…
Philippe
  • 548
  • 8
  • 24
0
votes
1 answer

Translating one DSL to another

I have a specific application DSL query language which I need to translate to Cypher. This means I get in runtime a string with my domain query language query (SQL like for the example) and need to create a Cypher query string that I can send to the…
Avner Levy
  • 6,601
  • 9
  • 53
  • 92
0
votes
0 answers

Why MATLAB's imclose and Opencv Python's MORPH_CLOSE show different outputs?

I was trying to convert some MATLAB codes to Python codes which are related to some image-processing. When I did imclose in MATLAB with a disc shape of 7, the hole in the original binary image was filled and it looks good. But when I did MORPH_CLOSE…
0
votes
1 answer

Running Python functions in CLISP

Are there any CLISP sources available? I could only find references to Stack. I'm trying to run a python definition in CLISP - any suggestions on how I go about doing this? I'm fairly familiar in writing definitions in CLISP, but not in python...…
0
votes
1 answer

C to MIPS Code translation problem with nested procedure

I need to tranlate piece of C code int main(){ int a, b, result; if(a == b) result = a*b; else result = assess(a, b); return result; } int assess(int a, int b){ if(b
Teurin
  • 11
  • 2
0
votes
2 answers

nesting structures, interfaces, and classes within an interface

I'm actually translating some C++ code (which I know very little about, and have never really used) to C#. Normally in C# I wouldn't find myself doing something like this, as it does seem a little odd, but with the way the code in C++ is setup, I…
zeboidlund
  • 9,731
  • 31
  • 118
  • 180
0
votes
1 answer

Calculate Euclidean distance matrix in C

I would like to convert this code which is written in MATLAB to C: matrix = [1 2 3; 4 5 6; 7 8 10] dis=zeros(9); for i=1:3 for j=1:3 dis(i,j)=sqrt(sum (abs((matrix(i,:)-matrix(j,:))))^2); end end The output is as follows: 0 9…
thomas
  • 785
  • 8
  • 7
0
votes
1 answer

Translating np.einsum() to MATLAB

I am having trouble understanding the documentation of np.einsum(). How are subscripts interpreted? I am trying to write np.einsum('a...c,b...c', Y, conj(Y)) where Y is a matrix of shape C, F, T on the original python. Also, due to previous…
havakok
  • 1,185
  • 2
  • 13
  • 45
0
votes
1 answer

How to use JavaParser to walk over all the nodes of AST (abstract syntax tree) of some Java source code?

I am trying to build a translator of Java source code to other object-oriented programming languages. For this I want to traverse the whole AST (generated by JavaParser) and gather each and every component of the Java source code and then…