Python to C# Code Explanation -
My ultimate purpose is to convert the code below in the Python to C #, but I want to do it myself by learning Python Syntax I think the code is recursive.
Creates polynomials of degree n with the variable of code. More specifically the list of expats for each variable.
def multichoose (n, k): if k & lt; 0 or N LT; 0: do not return "error" if not: return [[0] * n] if n: return [] if n == 1: return [[k]] return [[0] + val for val in multichoose ( N
There is a conversion [+] [+] [+] Val [1] I have done so far:
public double [ ] Multichoice (int n, int) {if (k & lt; 0 || n & lt; 0) {new exception ();} if (k == 0) {return [[0] * n]; / / I do not know what [[0] * n] is the meaning of syntax if (n == 0) {new double [0] returns; // I think it's just an empty array if ( N == 1) {new Double [1] {k}; // I think that this is just an empty array // do not underestimate part I [[0] + value in multicau (n-1, k)] + \ [[Wall [ 0] +1] + val [1:] valves for multichause (n, k-1)]}
My question is how do I change the python code?
<I will use the code to translate in C #:
-
[]
is empty list.Enumerable.lty
-
[x]
is an item in the list, X.enumerator Recurrence (x, 1)
-
[[0] * n]
is a list containing a 0 containing copy.enumerable Recurrence (Enumerable. Recurrence (0, N), 1)
-
[X for X in X]
is a list comprehension .Select Z from X - or - Z select (Y => X);
-
X + Y
(where x and y are lists) is a list insertion.The signature of the multiplexer will be: the public INIM map & lt; IEnumerable & lt; Double & gt; Enconirable (X, Y)
; & Gt; Multichause (int n, int k);
Comments
Post a Comment