c# - Mixing extension methods, generics and lambda expressions -


I'm porting Haskell / LiveScript each function to C # and I There are some difficulties: I sign this function (a → undefined) → [a] → [a] and I work very well with typing and lambda expressions in Haskell or LS, but C # confuses me. The last usage of this extension method should be the following:

  string [] str = {"Haskell", "Scheme", "Pearl", "Closer", "Live Script", "Erlang" }; Str.Each ((x) => Write console (x));  

And, along with that, my output should be:

  Haskell Scheme Pearl Closer LiveScript Enlarge  

My current Implementation of each :

  public static void each & lt; T & gt; (This IEnumberable  list, action off) {foreach (result in list) representative d = shut down; Object [] parameter = {results}; D.DynamicInvoke (parameter); }}  

The problem is that here I can not give a parameter in my lambda expression. I (x) = & gt; Can not ... .

How can I pass the parameter for lambda expression? Compared to C #, it was very easy to work with first-class tasks in Haskell, I'm just confused.

For those who do not know the implementation of each , it is used for its side effects, returns their list and lists them as a closure etching and logic Passing each value of the code should be implemented in PHP:

  public static functions each ($ func) {// where $ this- & gt; Value is a list foreach ($ -> value as $ x) {$ throw ($ xs); } Return $ this- & gt; Values; // or $ returned; In case of law-chaining  

Can anyone help me? I searched for it but it is not clear to me [and I do not want to use Linq]

You receive a action T & gt; Instead of one action you can call it Dynamic Invoke :

  public static absolute  T & gt; (It can apply directly instead of using IEnumberable & lt; T & gt; list, action & lt; T & gt; a) {foreign (result in the list) (one) (result); }}  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -