💾 Archived View for freeshell.de › gemlog › 2024-12-15_Polyglot_tomfoolery.gmi captured on 2024-12-17 at 11:04:54. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Polyglot tomfoolery ⬜

I once made a gemlog post that was also valid Whitespace code

Today I came across polyglot code by Paul at foo.zone

I thought "He's done valid C, C++, Perl and Raku, but I can do better!" so here it is as valid Whitespace too.

Any way, here it is.


#include <stdio.h>	  	  	   	  		 	 	 	  		 		  	 	 			 	   			 	 	 			    

 
#define $arg	function_argument    	  	   	 	 	   			 	  	  	 	  			 

#define my int 		 	    		  	 	 		 		   		 		   		 				
#define sub int  
#define BEGIN int main(void)	 	 
   	    	
my $arg;  			  		
sub hello() { 			  	 
  printf("Hello, welcome	to	the Fibonacci Numbers!\n");	 	
  printf("This program	is	all, valid C/C++/Perl/Raku and	Whitespace code!\n");
  printf("It calculates	all	fibonacci numbers	from	0 to	9!\n\n");
  return 0;			 	 	
}   	  			 
   	     
sub fibonacci() { 		 	  	
  my $n	=	$arg;   		
   		   		
  if ($n	<	2) {   	
   	return	$n; 			 
  } 		 				
   		   	 
  $arg =	$n-	1; 	  	
  my $fib1	= fibonacci();  		 
  $arg =	$n - 2;   
  my $fib2	=	fibonacci();  	 	
   		 	   
  return $fib1	+	$fib2;	 	  
}   	     
   		 				
BEGIN {  			 	  
  hello(); 	     
  my $i	=	0;  	 	
   		 		 	
  while ($i	<=	10) {				
   	$arg	= $i;  		
   	printf("fib(%d)	= %d\n",	$i,	fibonacci());  
   	$i++;	  	 	
  } 			 			
}   	     
   	 		  
   		 				
   		 		  
   		 		  
   		  	 	
   	  	   
   	 	 	 
 


 	  	  	   	 	     			  	  		 	  	 		 			  			 	  
    
   	 	 
   	    	
   		  	 	
   		  	  
   		 				
   		   		
   	     
   		  	 	
   		   		
   		    	
   			    
   			  		
   		  	 	
   			 	  
   		 	  	
   		 	   
   	 	 			
   	     
   		  	  
   		 			 
   		    	
   	     
   			 	 	
   		 	 		
   		    	
   	 	  	 
   	     
   		  	  
   		 			 
   		    	
   	     
   		 		  
   			  	 
   		  	 	
   	 	    
   	     
   		  	  
   		 			 
   		    	
   	     
   	 	 		
   	 	 		
   	    		
   	     
   		  	  
   		 			 
   		    	
   	     
   	    		
   	     
   		  	  
   		 	  	
   		 		  
   		    	
   			 		 
   	     
   	 		  
   		 		  
   		 		  
   		    	
   	     
   			  		
   		 	  	
   	     
   		 		 	
   		    	
   			  	 
   		  			
   		 				
   			  	 
   			    
   	     
   			  		
   		 	  	
   		 	   
   	 	 	  
   	  		 	
 


 	  	  	   	 	     			  	  		 	  	 		 			  			 	  
    
   	 	 
   	 	 
   	    	
   			  	
   	     
   		 				
   			 	  
   	     
   		    
   	     
   		 		 	
   		 				
   			  	 
   		  		 
   	     
   			  		
   			  	 
   		  	 	
   		   	 
   		 		 	
   			 	 	
   		 			 
   	     
   		 	  	
   		   		
   		   		
   		    	
   		 			 
   		 				
   		   	 
   		 	  	
   		  		 
   	     
   		 		  
   		 		  
   		    	
   	     
   			  		
   		  	 	
   			 	  
   		    	
   		 		  
   			 	 	
   		   		
   		 		  
   		    	
   		   		
   	     
   			 	  
   	  	  	
   		  		
 


 	  	  	   	 	     			  	  		 	  	 		 			  			 	  

	

   		  		  		 	  	 		   	  		 				 		 			  		    	 		   		 		   		 		 	  	
   	

 	  	  	   	  		 	 		    	 		 		   		 		   		 				 		   		
 
    	
					  
 			   	 
	  	
		 			  	  		  	 	 			 	   			 	 	 			  	  		 			  	  			 
 
    	
 
				   	
	  			    	

 	  	  	   	  		 	 		    	 		 		   		 		   		 				 		   		
 
 
 	 		  		  		 	  	 		   	  		 				 		 			  		    	 		   		 		   		 		 	  	
		  	  	
   	
 
				   	 
	  			    	

 	  	  	   	  		 	 		    	 		 		   		 		   		 				 		   		
 
 
 	 		  		  		 	  	 		   	  		 				 		 			  		    	 		   		 		   		 		 	  	
		  
 			 	  	 
				    
	
 	  	  	   	   		  			  	  		  	 	 		  	 	
 
	
 	  	  	   	   		  			  	  		  	 	 		  	 	
 
	
 	  	  	   	   		  			  	  		  	 	 		  	 	

	

   			  	  		  	 	 			 	   			 	 	 			  	  		 			  	  			 
 
 			 
	
 	  	  	   	   		  			  	  		  	 	 		  	 	

	

   	    	  	   	 	 	   			 	  	  	 	  			 

 	 		 	    		  	 	 		 		   		 		   		 				
   	 
    
		 
   		 		   		 				 		 				 			    
   	 
			   	 		
	  	
	  		  	 	 				    		 	  	 			 	  
   	
   	 
					 
 	 		  		  		 	  	 		   	  		 				 		 			  		    	 		   		 		   		 		 	  	
   	 
			    
   	 	   
   		   	 
   		 	  	
   		  		 
   	 	
 


 	  	  	   	 	     			  	  		 	  	 		 			  			 	  
	
 	    
   	     
   				 	
   	     
   	 	  	
   	 	
 


 	  	  	   	 	     			  	  		 	  	 		 			  			 	  
	
 	    
   	 	 
   	 
 


 	  	  	   	 	     			  	  		 	  	 		 			  			 	  
   	 
 
 			   	
	   		 
 
 		 		   		 				 		 				 			    

   		  	 	 				    		 	  	 			 	  







    	  	   	 	     			  	  		 	  	 		 			  			 	  
 
 
	   	  	   	 	     			  	  		 	  	 		 			  			 	   	   	   		 				 		 			  		  	 	
	
  
 
  	  	   	 	     			  	  		 	  	 		 			  			 	  

    	  	   	 	     			  	  		 	  	 		 			  			 	   	   	   		 				 		 			  		  	 	
 


	

    	  	   	  		 	 		    	 		 		   		 		   		 				 		   		
 
 
	   	  	   	  		 	 		    	 		 		   		 		   		 				 		   		 	    	  		    	 		  	  
 
 
		  	  	   	  		 	 		    	 		 		   		 		   		 				 		   		 	    	  		    	 		  	  

 	  	  	   	  		 	 	     	 		  	   		  	   			  	  		  	 	 			  		 			  		

	   	  	   	  		 	 	  				 		 		   		  	   	  	  	 		 			  		 	  	 			 	  

 
  	  	   	  		 	 	  			  		  	 	 			 			 	  	  	 		 			  		 	  	 			 	  

    	  	   	  		 	 	  				 		 		   		  	   	  	  	 		 			  		 	  	 			 	  
 
  	  	 
	   
 
  	  	   	  		 	 	  	  	 		 			  		 	  	 			 	   	  			  		  	 	 				    			 	  

    	  	   	  		 	 	  			  		  	 	 			 			 	  	  	 		 			  		 	  	 			 	  
 
  	  	 
	    
  	  	 
   	 
	  	 
			  
     
		  
    	
	       
		 
    	  	   	  		 	 	  	  	 		 			  		 	  	 			 	   	  			  		  	 	 				    			 	  
   	
	  	 
     
		  
  	  	 
	  	
	   	  	   	  		 	 	   	   		 				 		 			  		  	 	

 
  	  	   	  		 	 	  	  	 		 			  		 	  	 			 	   	  			  		  	 	 				    			 	  

    	  	   	  		 	 	   	   		 				 		 			  		  	 	
 

 	
 	
 
    	
	  	   	
		 
	

    	  	   	  		 	 	     	 		  	   		  	   			  	  		  	 	 			  		 			  		
   	        

    	  	   	  		 	 	 	 	   			  	  				  	 	    	  		 		   		 				 		   		 		 	 		
 
 			 
 
	   	  	   	  		 	 	  			  		  	 	 			 			 	    	  		 		   		   		 		 	 		
 
  	  	 
	  	   	 
	  	 	  		
	  	
	   	  	   	  		 	 	    		 		 	    		 	 		 	   		  			  	  		  	 	 		  	 	

    	  	   	  		 	 	 	     			  	  		  	 	 	 	 	   			  	  				  	
 
	 


 
  	  	   	  		 	 	 	 	   			  	  				  	 	    	  		 		   		 				 		   		 		 	 		

    	  	   	  		 	 	    		 		 	    		 	 		 	   		  			  	  		  	 	 		  	 	
 	  	
   	
	   			
	   	  	   	  		 	 	 	  	  		  	 	 	 	 	 	 			  		 		  	 	

 
  	  	   	  		 	 	 	     			  	  		  	 	 	 	 	   			  	  				  	

    	  	   	  		 	 	 	  	  		  	 	 	 	 	 	 			  		 		  	 	
 

   	 
	       

	

    	  	   	  		 	 	  			  		  	 	 			 			 	    	  		 		   		   		 		 	 		
 

   	 
	      	

	

    	  	   	  		 	 		    	 		 		   		 		   		 				 		   		 	    	  		    	 		  	  
 

  		

	

    	  	   	   		  			  	  		  	 	 		  	 	
   	
	  	    
		 
	

    	  	   	  		 	 	 	  		 		  	 	 			 	   			 	 	 			    
   	        
    
		    	     	  
    
		 
	

#Whitespace

#Programming

back to gemlog