2 using System.Collections.Generic;
4 class Disposable<T> : IDisposable
13 static Func<T[]> For<T> (List<T> list)
17 for (int i = 0; i < t.Length; ++i) {
25 static Func<T> Throw<T> (T t)
29 throw new ApplicationException (l.ToString ());
33 static Func<T> Do<T> (T t)
40 } while (default (T) != null);
46 static Func<T> Lock<T> (T t)
58 static Func<T> Catch<T> (T t)
63 throw new ApplicationException (l.ToString ());
70 static Func<T> Finally<T> (T t)
84 static Func<T> Using<T> (T t)
87 using (var d = new Disposable<T> ())
95 static Func<T> Switch<T> (T t)
106 static Func<List<T>> ForForeach<T> (T[] t)
110 return new List<T> () { e };
112 throw new ApplicationException ();
116 public static int Main ()
118 if (For (new List<int> { 5, 10 })() [1] != 10)
125 } catch (ApplicationException)
141 var t6 = Finally (5);
145 var t7 = Using (1.1);
149 var t8 = Switch (55);
153 var t9 = ForForeach (new [] { 4, 1 });
157 Console.WriteLine ("OK");