Task: Extend your language



C#: using System;
using System.Reflection;

namespace Extend_your_language
{
	

	class Program
	{
		
		public static void Main(string[] args)
		{
			Console.WriteLine();
			Console.WriteLine("Hello World!");
			Console.WriteLine();
			
			int x = 0;
			int y = 0;
			
			for(x=0;x<2;x++)
			{
				for(y=0;y<2;y++)
				{
					
					CONDITIONS( (x==0) , (y==0) ).
						IF2  ("METHOD1").
						ELSE1("METHOD2").
						ELSE2("METHOD3").
						ELSE ("METHOD4");
					
				}
			}
			
			Console.WriteLine();
			Console.Write("Press any key to continue . . . ");
			Console.ReadKey(true);
		}
		
		
		
		
		public static void METHOD1()
		{
			Console.WriteLine("METHOD 1 executed - both are true");
		}
		
		public static void METHOD2()
		{
			Console.WriteLine("METHOD 2 executed - first is true");
		}
		
		public static void METHOD3()
		{
			Console.WriteLine("METHOD 3 executed - second is true");
		}
		
		public static void METHOD4()
		{
			Console.WriteLine("METHOD 4 executed - both are false");
		}
		
		
		static int CONDITIONS(bool condition1, bool condition2)
		{
			int c = 0;
			if(condition1 && condition2)
				c = 0;
			else if(condition1)
				c = 1;
			else if(condition2)
				c = 2;
			else
				c = 3;
			
			return c;
		}
	}
	
	
	public static class ExtensionMethods
	{

		public static int IF2(this int value, string method)
		{
			if(value == 0)
			{
				MethodInfo m = typeof(Program).GetMethod(method);
				m.Invoke(null,null);
			}
			
			return value;
		}
		
		public static int ELSE1(this int value, string method)
		{
			if(value == 1)
			{
				MethodInfo m = typeof(Program).GetMethod(method);
				m.Invoke(null,null);
			}
			
			return value;
		}
		
		public static int ELSE2(this int value, string method)
		{
			if(value == 2)
			{
				MethodInfo m = typeof(Program).GetMethod(method);
				m.Invoke(null,null);
			}
			
			return value;
		}
		
		public static void ELSE(this int value, string method)
		{
			if(value == 3)
			{
				MethodInfo m = typeof(Program).GetMethod(method);
				m.Invoke(null,null);
			}
		}
		
	}
}








Fortran:       LOGICAL A,B		
      INTEGER IA,IB		
      EQUIVALENCE (IA,A),(IB,B)	

      WRITE (6,*) "Boolean tests via integers..."
      DO 199 IA = 0,1	
        DO 199 IB = 0,1		
          IF (IA) 666,99,109		
   99     IF (IB) 666,100,101		
  100     WRITE (6,*) "FF",IA,IB
          GO TO 199
  101     WRITE (6,*) "FT",IA,IB
          GO TO 199
  109     IF (IB) 666,110,111		
  110     WRITE (6,*) "TF",IA,IB
          GO TO 199
  111     WRITE (6,*) "TT",IA,IB
  199 CONTINUE		

      WRITE (6,*) "Boolean tests via integers and computed GO TO..."
      DO 299 IA = 0,1	
        DO 299 IB = 0,1		
          GO TO (200,201,210,211) 1 + IA*2 + IB	
  200     WRITE (6,*) "FF",IA,IB
          GO TO 299
  201     WRITE (6,*) "FT",IA,IB
          GO TO 299
  210     WRITE (6,*) "TF",IA,IB
          GO TO 299
  211     WRITE (6,*) "TT",IA,IB
  299 CONTINUE		

  300 WRITE (6,301)
  301 FORMAT (/,"Boolean tests via LOGICAL variables...",/
     1 " AB    IA    IB (IA*2 + IB)")
      A = .TRUE.	
      B = .TRUE.	
      DO I = 0,1	
        A = .NOT.A		
        DO J = 0,1		
          B = .NOT.B			
          WRITE (6,302) A,B,IA,IB,IA*2 + IB	
  302     FORMAT (1X,2L1,2I6,I8)		
        END DO			
      END DO		
      GO TO 999

  666 WRITE (6,*) "Huh?"

  999 CONTINUE
      END