WeixiangYan/CodeTransOcean huggingface dataset:
Task: Grayscale image






PHP: class BitmapGrayscale extends Bitmap {
  public function toGrayscale(){
    for ($i = 0; $i < $this->h; $i++){
      for ($j = 0; $j < $this->w; $j++){
        $l = ($this->data[$j][$i][0] * 0.2126)
           + ($this->data[$j][$i][1] * 0.7152)
           + ($this->data[$j][$i][2] * 0.0722);
        $l = round($l);
        $this->data[$j][$i] = array($l,$l,$l);
      }
    }
  }
}

$b = new BitmapGrayscale(16,16);
$b->fill(0,0,null,null, array(255,255,0));
$b->setPixel(0, 15, array(255,0,0));
$b->setPixel(0, 14, array(0,255,0));
$b->setPixel(0, 13, array(0,0,255));
$b->toGrayscale();
$b->writeP6('p6-grayscale.ppm');
Task: Literals_String



C#: string path = @"C:\Windows\System32";
string multiline = @"Line 1.
Line 2.
Line 3.";









Ada: ch : character := 'a';
Task: Literals_String




Go: ch := 'z'
ch = 122          
ch = '\x7a'       
ch = '\u007a'     
ch = '\U0000007a' 
ch = '\172'       








Ada: ch : character := 'a';
Task: Literals_String





Java:   char a = 'a';  
  String b = "abc";  
  char doubleQuote = '"';  
  char singleQuote = '\'';  
  String singleQuotes = "''";  
  String doubleQuotes = "\"\"";  







Ada: ch : character := 'a';
Task: Literals_String







Python: 'c' == "c" 
'text' == "text"
' " '
" ' "
'\x20' == ' '
u'unicode string'
u'\u05d0' 





Ada: ch : character := 'a';
Task: Literals_String

C: char ch = 'z';
Task: Literals_String



C#: string path = @"C:\Windows\System32";
string multiline = @"Line 1.
Line 2.
Line 3.";
Task: Literals_String


C++: auto strA = R"(this is
a newline-separated
raw string)";
Task: Literals_String





Java:   char a = 'a';  
  String b = "abc";  
  char doubleQuote = '"';  
  char singleQuote = '\'';  
  String singleQuotes = "''";  
  String doubleQuotes = "\"\"";
Task: Literals_String







Python: 'c' == "c" 
'text' == "text"
' " '
" ' "
'\x20' == ' '
u'unicode string'
u'\u05d0'
Task: Literals_String








VB:   Debug.Print "Tom said, ""The fox ran away."""
  Debug.Print "Tom said,
Task: Literals_String




Go: ch := 'z'
ch = 122          
ch = '\x7a'       
ch = '\u007a'     
ch = '\U0000007a' 
ch = '\172'
Task: Literals_String



C#: string path = @"C:\Windows\System32";
string multiline = @"Line 1.
Line 2.
Line 3.";








Fortran:       DIMENSION ATWT(12)
      PRINT 1
    1 FORMAT (12HElement Name,F9.4)
      DO 10 I = 1,12
        READ  1,ATWT(I)
   10   PRINT 1,ATWT(I)
      END
Task: Literals_String


C++: auto strA = R"(this is
a newline-separated
raw string)";









Fortran:       DIMENSION ATWT(12)
      PRINT 1
    1 FORMAT (12HElement Name,F9.4)
      DO 10 I = 1,12
        READ  1,ATWT(I)
   10   PRINT 1,ATWT(I)
      END
Task: Literals_String

C: char ch = 'z';










Fortran:       DIMENSION ATWT(12)
      PRINT 1
    1 FORMAT (12HElement Name,F9.4)
      DO 10 I = 1,12
        READ  1,ATWT(I)
   10   PRINT 1,ATWT(I)
      END
Task: Literals_String





Java:   char a = 'a';  
  String b = "abc";  
  char doubleQuote = '"';  
  char singleQuote = '\'';  
  String singleQuotes = "''";  
  String doubleQuotes = "\"\"";  






Fortran:       DIMENSION ATWT(12)
      PRINT 1
    1 FORMAT (12HElement Name,F9.4)
      DO 10 I = 1,12
        READ  1,ATWT(I)
   10   PRINT 1,ATWT(I)
      END
Task: Literals_String







Python: 'c' == "c" 
'text' == "text"
' " '
" ' "
'\x20' == ' '
u'unicode string'
u'\u05d0' 




Fortran:       DIMENSION ATWT(12)
      PRINT 1
    1 FORMAT (12HElement Name,F9.4)
      DO 10 I = 1,12
        READ  1,ATWT(I)
   10   PRINT 1,ATWT(I)
      END
Task: Literals_String








VB:   Debug.Print "Tom said, ""The fox ran away."""
  Debug.Print "Tom said, 



Fortran:       DIMENSION ATWT(12)
      PRINT 1
    1 FORMAT (12HElement Name,F9.4)
      DO 10 I = 1,12
        READ  1,ATWT(I)
   10   PRINT 1,ATWT(I)
      END
Task: Literals_String






PHP: 'c';                      # character
'hello';                  # these two strings are the same
"hello";
'Hi $name. How are you?'; # result: "Hi $name. How are you?"
"Hi $name. How are you?"; # result: "Hi Bob. How are you?"
'\n';                     # 2-character string with a backslash and "n"
"\n";                     # newline character
`ls`;                     # runs a command in the shell and returns the output as a string
<<END                     # Here-Document
Hi, whatever goes here gets put into the string,
including newlines and $variables,
until the label we put above
END;
<<'END'                   # Here-Document like single-quoted
Same as above, but no interpolation of $variables.
END;





Fortran:       DIMENSION ATWT(12)
      PRINT 1
    1 FORMAT (12HElement Name,F9.4)
      DO 10 I = 1,12
        READ  1,ATWT(I)
   10   PRINT 1,ATWT(I)
      END
Task: Literals_String



C#: string path = @"C:\Windows\System32";
string multiline = @"Line 1.
Line 2.
Line 3.";







COBOL: "This is a valid string."
'As is this.'
Task: Literals_String





Java:   char a = 'a';  
  String b = "abc";  
  char doubleQuote = '"';  
  char singleQuote = '\'';  
  String singleQuotes = "''";  
  String doubleQuotes = "\"\"";  





COBOL: "This is a valid string."
'As is this.'
Task: Literals_String







Python: 'c' == "c" 
'text' == "text"
' " '
" ' "
'\x20' == ' '
u'unicode string'
u'\u05d0' 



COBOL: "This is a valid string."
'As is this.'
Task: Literals_String








VB:   Debug.Print "Tom said, ""The fox ran away."""
  Debug.Print "Tom said, 


COBOL: "This is a valid string."
'As is this.'
Task: Literals_String




Go: ch := 'z'
ch = 122          
ch = '\x7a'       
ch = '\u007a'     
ch = '\U0000007a' 
ch = '\172'       






COBOL: "This is a valid string."
'As is this.'
Task: Literals_String






PHP: 'c';                      # character
'hello';                  # these two strings are the same
"hello";
'Hi $name. How are you?'; # result: "Hi $name. How are you?"
"Hi $name. How are you?"; # result: "Hi Bob. How are you?"
'\n';                     # 2-character string with a backslash and "n"
"\n";                     # newline character
`ls`;                     # runs a command in the shell and returns the output as a string
<<END                     # Here-Document
Hi, whatever goes here gets put into the string,
including newlines and $variables,
until the label we put above
END;
<<'END'                   # Here-Document like single-quoted
Same as above, but no interpolation of $variables.
END;
Task: Literals_String






PHP: 'c';                      # character
'hello';                  # these two strings are the same
"hello";
'Hi $name. How are you?'; # result: "Hi $name. How are you?"
"Hi $name. How are you?"; # result: "Hi Bob. How are you?"
'\n';                     # 2-character string with a backslash and "n"
"\n";                     # newline character
`ls`;                     # runs a command in the shell and returns the output as a string
<<END                     # Here-Document
Hi, whatever goes here gets put into the string,
including newlines and $variables,
until the label we put above
END;
<<'END'                   # Here-Document like single-quoted
Same as above, but no interpolation of $variables.
END;






Ada: ch : character := 'a';
Task: Literals_String






PHP: 'c';                      # character
'hello';                  # these two strings are the same
"hello";
'Hi $name. How are you?'; # result: "Hi $name. How are you?"
"Hi $name. How are you?"; # result: "Hi Bob. How are you?"
'\n';                     # 2-character string with a backslash and "n"
"\n";                     # newline character
`ls`;                     # runs a command in the shell and returns the output as a string
<<END                     # Here-Document
Hi, whatever goes here gets put into the string,
including newlines and $variables,
until the label we put above
END;
<<'END'                   # Here-Document like single-quoted
Same as above, but no interpolation of $variables.
END;




COBOL: "This is a valid string."
'As is this.'
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);
			}
		}
		
	}
}









Ada: with Ada.Text_IO; use Ada.Text_IO;

procedure Test_If_2 is
   
   type Two_Bool is range 0 .. 3;
   
   function If_2(Cond_1, Cond_2: Boolean) return Two_Bool is
      (Two_Bool(2*Boolean'Pos(Cond_1)) + Two_Bool(Boolean'Pos(Cond_2)));
   
begin
   for N in 10 .. 20 loop
      Put(Integer'Image(N) & " is ");
      case If_2(N mod 2 = 0, N mod 3 = 0) is
	 when 2#11# => Put_Line("divisible by both two and three.");
	 when 2#10# => Put_Line("divisible by two, but not by three.");
	 when 2#01# => Put_Line("divisible by three, but not by two.");
	 when 2#00# => Put_Line("neither divisible by two, nor by three.");
      end case;
   end loop;
end Test_If_2;
Task: Extend your language

C: 
#define if2(firsttest,secondtest,bothtrue,firsttrue,secondtrue,bothfalse)\
	switch(((firsttest)?0:2)+((secondtest)?0:1)) {\
		case 0: bothtrue; break;\
		case 1: firsttrue; break;\
		case 2: secondtrue; break;\
		case 3: bothfalse; break;\
	}











Ada: with Ada.Text_IO; use Ada.Text_IO;

procedure Test_If_2 is
   
   type Two_Bool is range 0 .. 3;
   
   function If_2(Cond_1, Cond_2: Boolean) return Two_Bool is
      (Two_Bool(2*Boolean'Pos(Cond_1)) + Two_Bool(Boolean'Pos(Cond_2)));
   
begin
   for N in 10 .. 20 loop
      Put(Integer'Image(N) & " is ");
      case If_2(N mod 2 = 0, N mod 3 = 0) is
	 when 2#11# => Put_Line("divisible by both two and three.");
	 when 2#10# => Put_Line("divisible by two, but not by three.");
	 when 2#01# => Put_Line("divisible by three, but not by two.");
	 when 2#00# => Put_Line("neither divisible by two, nor by three.");
      end case;
   end loop;
end Test_If_2;
Task: Extend your language




Go: package main

import "fmt"

type F func()

type If2 struct {cond1, cond2 bool}

func (i If2) else1(f F) If2 {
    if i.cond1 && !i.cond2 {
        f()
    }
    return i
}

func (i If2) else2(f F) If2 {
    if i.cond2 && !i.cond1 {
        f()
    }
    return i
}

func (i If2) else0(f F) If2 {
    if !i.cond1 && !i.cond2 {
        f()
    }
    return i
}

func if2(cond1, cond2 bool, f F) If2 {
    if cond1 && cond2 {
        f()
    }
    return If2{cond1, cond2}
}

func main() {
    a, b := 0, 1
    if2 (a == 1, b == 3, func() {
        fmt.Println("a = 1 and b = 3")
    }).else1 (func() {
        fmt.Println("a = 1 and b <> 3")
    }).else2 (func() {
        fmt.Println("a <> 1 and b = 3")
    }).else0 (func() {
        fmt.Println("a <> 1 and b <> 3")
    })

    
    a, b = 1, 0
    if2 (a == 1, b == 3, func() {
        fmt.Println("a = 1 and b = 3")
    }).else0 (func() {
        fmt.Println("a <> 1 and b <> 3")
    }).else1 (func() {
        fmt.Println("a = 1 and b <> 3")
    })
}








Ada: with Ada.Text_IO; use Ada.Text_IO;

procedure Test_If_2 is
   
   type Two_Bool is range 0 .. 3;
   
   function If_2(Cond_1, Cond_2: Boolean) return Two_Bool is
      (Two_Bool(2*Boolean'Pos(Cond_1)) + Two_Bool(Boolean'Pos(Cond_2)));
   
begin
   for N in 10 .. 20 loop
      Put(Integer'Image(N) & " is ");
      case If_2(N mod 2 = 0, N mod 3 = 0) is
	 when 2#11# => Put_Line("divisible by both two and three.");
	 when 2#10# => Put_Line("divisible by two, but not by three.");
	 when 2#01# => Put_Line("divisible by three, but not by two.");
	 when 2#00# => Put_Line("neither divisible by two, nor by three.");
      end case;
   end loop;
end Test_If_2;
Task: Extend your language





Java: public class If2 {

    public static void if2(boolean firstCondition, boolean secondCondition,
                           Runnable bothTrue, Runnable firstTrue, Runnable secondTrue, Runnable noneTrue) {
        if (firstCondition)
            if (secondCondition)
                bothTrue.run();
            else firstTrue.run();
        else if (secondCondition)
            secondTrue.run();
        else noneTrue.run();
    }
}







Ada: with Ada.Text_IO; use Ada.Text_IO;

procedure Test_If_2 is
   
   type Two_Bool is range 0 .. 3;
   
   function If_2(Cond_1, Cond_2: Boolean) return Two_Bool is
      (Two_Bool(2*Boolean'Pos(Cond_1)) + Two_Bool(Boolean'Pos(Cond_2)));
   
begin
   for N in 10 .. 20 loop
      Put(Integer'Image(N) & " is ");
      case If_2(N mod 2 = 0, N mod 3 = 0) is
	 when 2#11# => Put_Line("divisible by both two and three.");
	 when 2#10# => Put_Line("divisible by two, but not by three.");
	 when 2#01# => Put_Line("divisible by three, but not by two.");
	 when 2#00# => Put_Line("neither divisible by two, nor by three.");
      end case;
   end loop;
end Test_If_2;
Task: Extend your language







Python: a, b = 1, 0

if (c1 := a == 1) and (c2 := b == 3):
  print('a = 1 and b = 3')
elif c1:
  print('a = 1 and b <> 3')
elif c2:
  print('a <> 1 and b = 3')
else:
  print('a <> 1 and b <> 3')





Ada: with Ada.Text_IO; use Ada.Text_IO;

procedure Test_If_2 is
   
   type Two_Bool is range 0 .. 3;
   
   function If_2(Cond_1, Cond_2: Boolean) return Two_Bool is
      (Two_Bool(2*Boolean'Pos(Cond_1)) + Two_Bool(Boolean'Pos(Cond_2)));
   
begin
   for N in 10 .. 20 loop
      Put(Integer'Image(N) & " is ");
      case If_2(N mod 2 = 0, N mod 3 = 0) is
	 when 2#11# => Put_Line("divisible by both two and three.");
	 when 2#10# => Put_Line("divisible by two, but not by three.");
	 when 2#01# => Put_Line("divisible by three, but not by two.");
	 when 2#00# => Put_Line("neither divisible by two, nor by three.");
      end case;
   end loop;
end Test_If_2;
Task: Extend your language

C: 
#define if2(firsttest,secondtest,bothtrue,firsttrue,secondtrue,bothfalse)\
	switch(((firsttest)?0:2)+((secondtest)?0:1)) {\
		case 0: bothtrue; break;\
		case 1: firsttrue; break;\
		case 2: secondtrue; break;\
		case 3: bothfalse; break;\
	}
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);
			}
		}
		
	}
}
Task: Extend your language





Java: public class If2 {

    public static void if2(boolean firstCondition, boolean secondCondition,
                           Runnable bothTrue, Runnable firstTrue, Runnable secondTrue, Runnable noneTrue) {
        if (firstCondition)
            if (secondCondition)
                bothTrue.run();
            else firstTrue.run();
        else if (secondCondition)
            secondTrue.run();
        else noneTrue.run();
    }
}
Task: Extend your language







Python: a, b = 1, 0

if (c1 := a == 1) and (c2 := b == 3):
  print('a = 1 and b = 3')
elif c1:
  print('a = 1 and b <> 3')
elif c2:
  print('a <> 1 and b = 3')
else:
  print('a <> 1 and b <> 3')
Task: Extend your language




Go: package main

import "fmt"

type F func()

type If2 struct {cond1, cond2 bool}

func (i If2) else1(f F) If2 {
    if i.cond1 && !i.cond2 {
        f()
    }
    return i
}

func (i If2) else2(f F) If2 {
    if i.cond2 && !i.cond1 {
        f()
    }
    return i
}

func (i If2) else0(f F) If2 {
    if !i.cond1 && !i.cond2 {
        f()
    }
    return i
}

func if2(cond1, cond2 bool, f F) If2 {
    if cond1 && cond2 {
        f()
    }
    return If2{cond1, cond2}
}

func main() {
    a, b := 0, 1
    if2 (a == 1, b == 3, func() {
        fmt.Println("a = 1 and b = 3")
    }).else1 (func() {
        fmt.Println("a = 1 and b <> 3")
    }).else2 (func() {
        fmt.Println("a <> 1 and b = 3")
    }).else0 (func() {
        fmt.Println("a <> 1 and b <> 3")
    })

    
    a, b = 1, 0
    if2 (a == 1, b == 3, func() {
        fmt.Println("a = 1 and b = 3")
    }).else0 (func() {
        fmt.Println("a <> 1 and b <> 3")
    }).else1 (func() {
        fmt.Println("a = 1 and b <> 3")
    })
}
Task: Extend your language

C: 
#define if2(firsttest,secondtest,bothtrue,firsttrue,secondtrue,bothfalse)\
	switch(((firsttest)?0:2)+((secondtest)?0:1)) {\
		case 0: bothtrue; break;\
		case 1: firsttrue; break;\
		case 2: secondtrue; break;\
		case 3: bothfalse; break;\
	}










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
Task: Extend your language





Java: public class If2 {

    public static void if2(boolean firstCondition, boolean secondCondition,
                           Runnable bothTrue, Runnable firstTrue, Runnable secondTrue, Runnable noneTrue) {
        if (firstCondition)
            if (secondCondition)
                bothTrue.run();
            else firstTrue.run();
        else if (secondCondition)
            secondTrue.run();
        else noneTrue.run();
    }
}






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
Task: Extend your language







Python: a, b = 1, 0

if (c1 := a == 1) and (c2 := b == 3):
  print('a = 1 and b = 3')
elif c1:
  print('a = 1 and b <> 3')
elif c2:
  print('a <> 1 and b = 3')
else:
  print('a <> 1 and b <> 3')




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