linq - Learning Haskell: list comprehensions in C# -


The following code is in Haskel, how do I write the same function in C #?

  class xx = [pi * r ^ 2 | R & lt; - xs]  

Just to clarify ... The code above is a function, which takes the form of a circle as the list of inputs. Expression calculates the area of ​​each circle in the input list.

I know that in C #, I have a question about looping through a list and calculating the area of ​​each circle and the area with a circle area ... Is the code above C # Can be written equally, perhaps using lambda bhav or LINQ?

Using:

  IEnumerable < Double & gt; Squirearia (IINMERABLE & LEFTINUM; ET ADS; XS) {Return to monastery from R. Choose PI * R * R; }  

or

  IEnumerable & lt; Double & gt; SquareAiria (IEnumerable & lt; int & gt; xs) {returns xs.Select (r = & gt; Math.PI * R * R);  

which is very close to Haskell

  class erea x = map (\ r -> pi * r * r) xs  < / Pre> 

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -