recursion - Can't recursively call function in VB.NET -


As a little program to learn about language, I apply linq to The method of trying (usually known as a map outside of VB), although it seems that I have participated in a small problem, it will not let me call the function again because It assumes that the type does not match

here is the code:

  Iterator function map (A, B (As a joke, A, B), In the form of input (AK)) as IEnumerable (B) If there is nothing in input then there is no use when the fun (head) input map (Fun, Input)) 'Error Here End End Function   

Note here that head () is a function that is the first element of the input list , And tail () is a method that gives everything, but the first element

I did a test first For what would a function I (A, B) was possible to have a function, such as I;

/ Code> has the following signature:
  In the form of the function head (tk) (i.e. as IEnumerable (tk)) as t ... and function Function TEL (TK) (as IEInumerable (T)) as IEnumerable (TK) ... end function   

Then the query in the row generates the following error (signal Always include error messages in your SO question Data type of type parameter (A, B) (In the form of draft. Function (A, B) input, input as the system. Editor. Generic.list (ASK)) as a system. Colllections.Generic IEnumerable (BK) These arguments can not be estimated from. Specifying the data type can clearly correct this error.

Then let's ask for the error message:

  Iterator function map ( Interesting as A, B) (Music, A, B), In the form of Input (AK) as IEnumerable (B) ... Map (A, B) (Interesting, Tail (Input)) ... function   

and we get a more specific error:

Selection. Generic 'System.Collections.Generic.List (A)'.

It makes sense: Tail a IEnumerable returns map to a The list requires . Since map does not use any list-specific properties, let's just make the map more generous in its input:

  Iterator Function map, like A, B) (such as A, B), as IEnumerable (AK) as input) like IEnumerable (B) ... end function   

now , Everything compiled properly In fact, we can now remove (A, B) again, because VB.NET is required to fix the required data type of the normal type parameter It can be assumed: Interesting as < / Html>

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -