argv   IS    $1
argc   IS    $0
i      IS    $2

       LOC   #100
Main   LOC   @
       SETL  i,1               % i = 1
Loop   CMP   $3,argc,2         % argc < 2 ?
       BN    $3,1F             % then jump to end
       XOR   $255,$255,$255    % clear $255
       8ADDU $255,i,argv       % i*8 + argv
       LDOU  $255,$255,0       % argv[i]
       TRAP  0,Fputs,StdOut    % write the argument
       GETA  $255,NewLine      % add a newline
       TRAP  0,Fputs,StdOut
       INCL  i,1               % increment index
       SUB   argc,argc,1       % argc--
       BP    argc,Loop         % argc > 0? then Loop
1H     LOC   @
       XOR   $255,$255,$255    % exit(0)
       TRAP  0,Halt,0

NewLine BYTE #a,0


(* This is a comment.
   It may extend across multiple lines. *)

{ Alternatively curly braces
  can be used. }

/* C-style multi-line comments
   are supported  */

// and single-line C++ style comments too


MODULE try;

FROM  Arguments  IMPORT  GetArgs, ArgTable, GetEnv;
FROM  InOut      IMPORT  WriteCard, WriteLn, WriteString;

VAR   count, item        : SHORTCARD;
      storage            : ArgTable;

BEGIN
   GetArgs (count, storage);
   WriteString ('Count =');     WriteCard (count, 4);   WriteLn;
   item := 0;
   REPEAT
      WriteCard (item, 4);
      WriteString (' :  ');
      WriteString (storage^ [item]^);
      WriteLn;
      INC (item)
   UNTIL item = count
END try.


MODULE Args EXPORTS Main;

IMPORT IO, Params;

BEGIN
  IO.Put(Params.Get(0) & "\n");
  IF Params.Count > 1 THEN
    FOR i := 1 TO Params.Count - 1 DO
      IO.Put(Params.Get(i) & "\n");
    END;
  END;
END Args.


//
// command-line arguments
//

// output all arguments
for i in range(0, len(args) - 1)
	println args[i]
end


/* command line arguments, neko */
var argc = $asize($loader.args)

/* Display count and arguments, indexed from 0, no script name included */
$print("There are ", argc, " arguments\n")

var arg = 0
while arg < argc $print($loader.args[arg ++= 1], "\n")


/* This is a
multi-line comment */

//This is a single-line comment


// This is a comment

/*
   This is a comment
   that spans multiple
   lines
*/


#this is a comment
!print "this is not a comment, obviously" #this is a comment as well


# This is a regular comment.

? "This is an Updoc comment, which
> is an executable example or test case.".split(" ")
# value: ["This", "is", "an", "Updoc", "comment,", "which
#        is", "an", "executable", "example", "or", "test", "case."]


using System;
using System.Console;

module CLArgs
{
    Main(args : array[string]) : void
    {
        foreach (arg in args) Write($"$arg "); // using the array passed to Main(), everything after the program name
        Write("\n");

        def cl_args = Environment.GetCommandLineArgs(); // also gets program name
        foreach (cl_arg in cl_args) Write($"$cl_arg ");
    }
}


/* NetRexx */
-- sample arguments: -c "alpha beta" -h "gamma"
say "program arguments:" arg


import os
echo "program name: ", getAppFilename()
echo "Arguments:"
for arg in commandLineParams():
  echo arg


MODULE CommandLineArguments;
IMPORT
  NPCT:Args,
  Out := NPCT:Console;

BEGIN
  Out.String("Args number: ");Out.Int(Args.Number(),0);Out.Ln;
  Out.String("0.- : ");Out.String(Args.AsString(0));Out.Ln;
  Out.String("1.- : ");Out.String(Args.AsString(1));Out.Ln;
  Out.String("2.- : ");Out.String(Args.AsString(2));Out.Ln;
  Out.String("3.- : ");Out.String(Args.AsString(3));Out.Ln;
  Out.String("4.-: ");Out.String(Args.AsString(4));Out.Ln
END CommandLineArguments.


class Line {
  function : Main(args : String[]) ~ Nil {
    each(i : args) {
      args[i]->PrintLine();
    };
  }
}


666 ; this is an end-of-line comment

#|
 This is a multi-line comment
 Nesting is not allowed
|#

;; The (info <name> [<string>)] function associates a symbol and a comment
;; These info strings are saved in permanent memory (local storage)
;; Unicode characters may be used, as everywhere in the language

(define mynumber 666) → mynumber
(info 'mynumber "👀 Symbols may be commented with an information string 👺")
(info 'mynumber) → displays the above inside the 'info' field.


[This is a comment]
[
And so
is
this
]
[But in 1949 they wouldn't have been]


NSArray *args = [[NSProcessInfo processInfo] arguments];
NSLog(@"This program is named %@.", [args objectAtIndex:0]);
NSLog(@"There are %d arguments.", [args count] - 1);
for (i = 1; i < [args count]; ++i){
    NSLog(@"the argument #%d is %@", i, [args objectAtIndex:i]);
}


let () =
  Printf.printf "This program is named %s.\n" Sys.argv.(0);
  for i = 1 to Array.length Sys.argv - 1 do
    Printf.printf "the argument #%d is %s\n" i Sys.argv.(i)
  done


functor
import Application System
define
   ArgList = {Application.getArgs plain}
   {ForAll ArgList System.showInfo}
   {Application.exit 0}
end


-- inline comment, continues until new line


//single line comment

/*multiple line
comment*/


my @params = @ARGV;
my $params_size = @ARGV;
my $second = $ARGV[1];
my $fifth = $ARGV[4];


with javascript_semantics
constant cmd = command_line()
?cmd
if cmd[1]=cmd[2] then
    printf(1,"Compiled executable name: %s\n",{cmd[1]})
else
    printf(1,"Interpreted (using %s) source name: %s\n",cmd[1..2])
end if
if length(cmd)>2 then
  puts(1,"Command line arguments:\n")
  for i = 3 to length(cmd) do
    printf(1,"#%d : %s\n",{i,cmd[i]})
  end for
end if


<?php
$program_name = $argv[0];
$second_arg = $argv[2];
$all_args_without_program_name = array_shift($argv);


-- a single line comment

{- a multiline comment
   {- can be nested -}
-}


% Erlang comments begin with "%" and extend to the end of the line.


main(ARGS) =>
  println(ARGS).
main(_) => true.


#!/usr/bin/picolisp /usr/lib/picolisp/lib.l

(de c ()
   (prinl "Got 'c': " (opt)) )

(de h ()
   (prinl "Got 'h': " (opt)) )

(load T)
(bye)


/* The entire command line except the command word itself is passed */
/* to the parameter variable in PL/I.                               */
program: procedure (command_line) options (main);
   declare command_line character (100) varying;

...

end program;


lvars arg;
for arg in poparglist do
   printf(arg, '->%s<-\n');
endfor;


$i = 0
foreach ($s in $args) {
    Write-Host Argument (++$i) is $s
}


! Standard ERRE comments begin with ! and extend to the end of the line

PRINT("this is code") ! comment after statement


// this comments to the end of the line
(* this comments a region
   which can be multi-line *)


! Comments starts with "! "
#! Or with "#! "
! and last until the end of the line

USE: multiline
/* The multiline vocabulary implements
   C-like multiline comments. */


using system;

printf "There are %d command line argumants\n" argc;
puts "They are " $$ map (puts) argv;


If OpenConsole()
  Define n=CountProgramParameters()
  PrintN("Reading all parameters")
  While n
    PrintN(ProgramParameter())
    n-1
  Wend
  Print(#CRLF$+"Press Enter")
  Input()
  CloseConsole()
EndIf


import sys
program_name = sys.argv[0]
arguments = sys.argv[1:]
count = len(arguments)


R CMD BATCH --vanilla --slave '--args a=1 b=c(2,5,6)' test.r test.out


# with arguments supplied
$ raku -e 'sub MAIN($x, $y) { say $x + $y }' 3 5
8

# missing argument:
$ raku -e 'sub MAIN($x, $y) { say $x + $y }' 3
Usage:
-e '...' x y


/* Start comment block
 My Life Story
 */

// set up my bank account total
bank_account_total = 1000000 // Wish this was the case


# Comments starts with "#"
# and last until the end of the line


Function Foo(n) =
    {Comments within a function are enclosed within curly brackets.}
    {You can make multi-line comments
        such as this one.}
    n:=n^2 + 3n - 222;   {Comments can go after a semicolon.}
    n:=n+1;
    n.

; comments between functions are preceded by semicolons, like this

Function Bar(n) =
    2n-1.


PRINT "This program is named "; Command$(0)
FOR i=1 TO CommandCount
    PRINT "The argument "; i; " is "; Command$(i)
NEXT i


ARGS print

stack (6 items)
 0 => "raven"
 1 => "myprogram"
 2 => "-c"
 3 => "alpha beta"
 4 => "-h"
 5 => "gamma"


Function Run(args() as String) As Integer
  For each arg As String In args
    Stdout.WriteLine(arg)
  Next
End Function


see copy("=",30) + nl
see "Command Line Parameters" + nl
see "Size : " + len(sysargv) + nl
see sysargv
see copy("=",30) + nl
for x = 1 to len(sysargv)
    see x + nl
next


use std::env;

fn main(){
    let args: Vec<_> = env::args().collect();
    println!("{:?}", args);
}


v This is the Fish version of the Integer sequence task
>0>:n1+v all comments here
  ^o" "< still here
And of course here :)


\ The backslash skips everything else on the line
( The left paren skips everything up to the next right paren on the same line)


C     This would be some kind of comment
C     Usually one would avoid columns 2-6 even in a comment.


' FB 1.05.0 Win64

' This a single line comment

REM This is another way of writing a single line comment

/'
  This is a
  multi-line
  comment
'/

/'
  Multi-line comments
  /'
    can also be nested
  '/
  like this
'/


variable a;
foreach a (__argv)
  print(a);


class MAIN is
  main(args:ARRAY{STR}) is
    loop
      #OUT + args.elt! + "\n";
    end;
  end;
end;


object CommandLineArguments extends App {
    println(s"Received the following arguments: + ${args.mkString("", ", ", ".")}")
}


 (define (main args)
  (for-each (lambda (arg) (display arg) (newline)) args))


$ include "seed7_05.s7i";

const proc: main is func
  local
    var integer: i is 0;
  begin
    writeln("This program is named " <& name(PROGRAM) <& ".");
    for i range 1 to length(argv(PROGRAM)) do
      writeln("The argument #" <& i <& " is " <& argv(PROGRAM)[i]);
    end for;
  end func;


StartupArguments do: [| :arg | inform: arg]


// This is a single-line comment
/*  This is a comment
    that spans multiple lines
    and so on.
*/


-- Single-line comment

-- Multi-line
-- comment (yes, just several single-line comments).


//  Single line comment
'   Single line comment
rem Single line comment
/*  Single line comment  */

/*
  Multiline
  comment
*/


//Comment (No space required)
# Comment (Space required)
REM Comment (Space require)
PRINT "This is an inline comment."//Comment (No space required)
END


(1 to: Smalltalk getArgc) do: [ :i |
  (Smalltalk getArgv: i) displayNl
]


print ("This program is named " ^ CommandLine.name () ^ ".\n");
val args = CommandLine.arguments ();
Array.appi
  (fn (i, x) => print ("the argument #" ^ Int.toString (i+1) ^ " is " ^ x ^ "\n"))
  (Array.fromList args);


let args = Process.arguments
println("This program is named \(args[0]).")
println("There are \(args.count-1) arguments.")
for i in 1..<args.count {
  println("the argument #\(i) is \(args[i])")
}


if { $argc > 1 } {
    puts [lindex $argv 1]
}


[ arglist array.get type cr ] is show-arg
[ dup . char: = emit space ] is #=
1 #args [ i #= show-arg ] countedLoop


@(next :args)
@(collect)
@arg
@(end)
@(output)
My args are: {@(rep)@arg, @(last)@[email protected](end)}
@(end)


 ' This whole line is a comment and is ignored by the gambas interpreter
 print "Hello" ' Comments after an apostrophe are ignored
 '' A bold-style comment
 ' TODO:  To Do  comment will appear in Task Bar
 ' FIXME: Fix Me comment will appear in Task Bar
 ' NOTE:  Note   commnet will appear in Task Bar


( this is a test comment... o.O ) 1 2 + .


! comment starts with "!" and continues to end of line


#
# command-line arguments
#

# output all arguments
for (decl int i) (< i (size args)) (inc i)
        out args<i> endl console
end for


#import std

#executable ('parameterized','')

clarg = <.file$[contents: --<''>+ _option%LP]>+ ~command.options


$stack puts

./args.v a b c
=[args.v a b c]


'Command line arguments can be accessed all together by

For Each arg In Wscript.Arguments
    Wscript.Echo "arg=", arg
Next

'You can access only the named arguments such as /arg:value

For Each arg In Wscript.Arguments.Named
    Wscript.Echo "name=", arg, "value=", Wscript.Arguments.Named(arg)
Next

'Or just the unnamed arguments

For Each arg In Wscript.Arguments.Unnamed
    Wscript.Echo "arg=", arg
Next


Sub Main(ByVal args As String())
    For Each token In args
        Console.WriteLine(token)
    Next
End Sub


define color $00
define looptemp $01

loop_1wide:
lda color
sta $0200,x
inc color
inx
bne loop_1wide

loop_2wide:
lda color
sta $0300,x
inx
sta $0300,x
inc color
inx
bne loop_2wide

lda #0
tax
tay
sta color
sta looptemp   ;reset ram

loop_3wide:
lda color
sta $0400,x
inc looptemp
inx

sta $0400,x
inc looptemp
inx

sta $0400,x
inc looptemp
inc color
inx

lda looptemp
cmp #$1e
bne loop_3wide

lda color    ;loop overhead
sta $0400,x  ;can't fit all of this stripe.
	     ;two columns will have to do.
inx
lda color
sta $0400,x
inx

lda #0
sta color
sta looptemp  ;reset color and looptemp
iny
cpy #$08      ;check secondary loop counter
bne loop_3wide

lda #0
tax
tay
sta color
sta looptemp   ;reset ram

loop_4wide:
lda color
sta $0500,x
inx
inc looptemp

sta $0500,x
inx
inc looptemp

sta $0500,x
inx
inc looptemp

sta $0500,x
inc color
inc looptemp
inx

lda looptemp
cmp #$20
bne loop_4wide
lda #0
sta looptemp
sta color

iny
cpy #$8
bcc loop_4wide

brk        ;program end


// Comment continues until end of line

/* Comment lasts between delimiters */


// comment starts with "//" and continues to the end of the line


# this is a comment

# backslash continues \
a comment to the next \
line or lines


// this is a single line comment
/* this is
   a multi-line
   block comment.
/* It does not nest */


import os

fn main() {
	for i, x in os.args[1..] {
		println("the argument #$i is $x")
	}
}


import "os" for Process

System.print(Process.arguments)


int C;
[loop   [C:= ChIn(8);
        if C = \EOF\$1A then quit;
        ChOut(0, C);
        ];
CrLf(0);
]


PROC Main()
  BYTE
    i,
    CH=$02FC, ;Internal hardware value for last key pressed
    PALNTSC=$D014, ;To check if PAL or NTSC system is used
    PCOLR0=$02C0,PCOLR1=$02C1,
    PCOLR2=$02C2,PCOLR3=$02C3,
    COLOR0=$02C4,COLOR1=$02C5,
    COLOR2=$02C6,COLOR3=$02C7,
    COLOR4=$02C8

  Graphics(10)
  PCOLR0=$04 ;gray
  PCOLR1=$00 ;black
  IF PALNTSC=15 THEN
    PCOLR2=$42 ;red for NTSC
    PCOLR3=$C6 ;green for NTSC
    COLOR0=$84 ;blue for NTSC
    COLOR1=$66 ;magenta for NTSC
    COLOR2=$A6 ;cyan for NTSC
    COLOR3=$FC ;yellow for NTSC
  ELSE
    PCOLR2=$22 ;red for PAL
    PCOLR3=$B6 ;green for PAL
    COLOR0=$74 ;blue for PAL
    COLOR1=$48 ;magenta for PAL
    COLOR2=$96 ;cyan for PAL
    COLOR3=$EC ;yellow for PAL
  FI
  COLOR4=$0F ;white

  FOR i=0 TO 79
  DO
    Color=i MOD 8+1
    Plot(i,0) DrawTo(i,47)

    Color=i/2 MOD 8+1
    Plot(i,48) DrawTo(i,95)

    Color=i/3 MOD 8+1
    Plot(i,96) DrawTo(i,143)

    Color=i/4 MOD 8+1
    Plot(i,144) DrawTo(i,191)
  OD

  DO UNTIL CH#$FF OD
  CH=$FF
RETURN


package  {

    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;

    public class ColourPinstripe extends Sprite {

        public function ColourPinstripe():void {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void {

            var colours:Array = [ 0xFF000000, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFF00FF, 0xFF00FFFF, 0xFFFFFF00, 0xFFFFFFFF ];
            var data:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0xFFFFFFFF);
            data.lock();

            var w:uint = data.width, h:uint = data.height / 4;
            var x:uint, y:uint = 0, i:uint, px:uint, colourIndex:uint, colour:uint, maxy:uint = h;

            for ( i = 1; i <= 4; i++ ) {

                for ( ; y < maxy; y++ ) {
                    colour = 0xFF000000;
                    colourIndex = 0;
                    px = 1;

                    for ( x = 0; x < w; x++ ) {

                        if ( px == i ) {
                            colourIndex = (colourIndex > 7) ? 0 : colourIndex + 1;
                            colour = colours[colourIndex];
                            px = 1;
                        }
                        else px++;

                        data.setPixel32(x, y, colour);

                    }
                }

                maxy += h;

            }

            data.unlock();
            addChild(new Bitmap(data));
        }

    }

}


# this is a comment
show 123        # this too is a comment


100 REM Standard BASIC comments begin with "REM" (remark) and extend to the end of the line
110 PRINT "this is code": REM comment after statement


with SDL.Video.Windows.Makers;
with SDL.Video.Renderers.Makers;
with SDL.Video.Palettes;
with SDL.Events.Events;

procedure Colour_Pinstripe_Display is

   Width   : constant := 1_200;
   Height  : constant := 800;

   Window   : SDL.Video.Windows.Window;
   Renderer : SDL.Video.Renderers.Renderer;
   Event    : SDL.Events.Events.Events;

   procedure Draw_Pinstripe (Line_Width   : in Integer;
                             Line_Height  : in Integer;
                             Screen_Width : in Integer;
                             Y            : in Integer)
   is
      type Colour_Range is (Black, Red, Green, Blue, Magenta, Cyan, Yellow, White);
      Colours : constant array (Colour_Range) of SDL.Video.Palettes.Colour
        := (Black   => (0, 0, 0, 255),     Red   => (255, 0, 0, 255),
            Green   => (0, 255, 0, 255),   Blue  => (0, 0, 255, 255),
            Magenta => (255, 0, 255, 255), Cyan  => (0, 255, 255, 255),
            Yellow  => (255, 255, 0, 255), White => (255, 255, 255, 255));
      Col   : Colour_Range := Colour_Range'First;
      Count : constant Integer := Screen_Width / Line_Width;
   begin
      for A in 0 .. Count loop
         Renderer.Set_Draw_Colour (Colour => Colours (Col));
         Renderer.Fill (Rectangle => (X => SDL.C.int (A * Line_Width), Y => SDL.C.int (Y),
                                      Width  => SDL.C.int (Line_Width),
                                      Height => SDL.C.int (Line_Height)));
         Col := (if Col = Colour_Range'Last
                   then Colour_Range'First
                   else Colour_Range'Succ (Col));
      end loop;
   end Draw_Pinstripe;

   procedure Wait is
      use type SDL.Events.Event_Types;
   begin
      loop
         while SDL.Events.Events.Poll (Event) loop
            if Event.Common.Event_Type = SDL.Events.Quit then
               return;
            end if;
         end loop;
         delay 0.100;
      end loop;
   end Wait;

begin
   if not SDL.Initialise (Flags => SDL.Enable_Screen) then
      return;
   end if;

   SDL.Video.Windows.Makers.Create (Win      => Window,
                                    Title    => "Pinstripe",
                                    Position => SDL.Natural_Coordinates'(X => 10, Y => 10),
                                    Size     => SDL.Positive_Sizes'(Width, Height),
                                    Flags    => 0);
   SDL.Video.Renderers.Makers.Create (Renderer, Window.Get_Surface);

   Draw_Pinstripe (1, Height / 4, Width, 0);
   Draw_Pinstripe (2, Height / 4, Width, 200);
   Draw_Pinstripe (3, Height / 4, Width, 400);
   Draw_Pinstripe (4, Height / 4, Width, 600);
   Window.Update_Surface;

   Wait;
   Window.Finalize;
   SDL.Finalise;
end Colour_Pinstripe_Display;


i code = True -- I am a comment.

{- I am also
   a comment. {-comments can be nested-}
   let u x = x x (this code not compiled)
   Are you? -}

-- |This is a Haddock documentation comment for the following code
i code = True
-- ^This is a Haddock documentation comment for the preceding code

{-|
  This is a Haddock documentation block comment
-}
i code = True


// Single line commment.

/*
   Multiple
   line
   comment.
*/


! a comment starts with a "!" and ends at the end of the line


! All Hope comments begin with "!" and extend to the end of the line


        .org 0x08000000                        ;cartridge ROM begins here

        b ProgramStart                         ;branch around the cartridge header

        ;;;; cartridge header goes here

	.equ SCREEN_WIDTH,240                  ;some labels for convenience
	.equ SCREEN_HEIGHT,160

ProgramStart:
	mov sp,#0x03000000			;set up stack pointer (we won't be using it but it's a good practice to do so anyway

	mov r4,#0x04000000  		        ;DISPCNT (LCD Control Register)
	mov r2,#0x403    			;4= Layer 2 on / 3= ScreenMode 3 (Bitmap Graphics, vram at 0x06000000)

	str r2,[r4]         	                ;now the screen is visible.

	mov r0,#0x06000000			;VRAM BASE (2 BYTES PER PIXEL)
	mov r1,#0				;COLOR TO STORE (INIT TO ZERO, WILL GET FILLED IN LATER)

	adr r4,palArray				;get address of palette
	mov r5,#0				;index into palArray
	mov r6,#19200				;this is one quarter of the screen

	add r7,r0,r6				;MOV R7, #0x06004B00
	add r8,r7,r6				;MOV R8, #0x06009600
	add r9,r8,r6				;MOV R9, #0x0600E100
	add r10,r9,r6				;MOV R10,#0x06012C00

loop_pinstripe_firstQuarter:
	ldrH r1,[r4,r5]
	strH r1,[r0],#2				;store into video memory and post-inc by 2.
	add r5,r5,#2                            ;next color in palette
	and r5,r5,#0x0F				;prevents indexing out of bounds
	cmp r0,r7                               ;have we reached the end of this quarter of the screen?
	blt loop_pinstripe_firstQuarter         ;if not, keep drawing

loop_pinstripe_secondQuarter:
	ldrH r1,[r4,r5]
	strH r1,[r0],#2				;post-inc by 2 after the store
	strH r1,[r0],#2				;post-inc by 2 after the store
	add r5,r5,#2
	and r5,r5,#0x0F
	cmp r0,r8
	blt loop_pinstripe_secondQuarter

loop_pinstripe_thirdQuarter:
	ldrH r1,[r4,r5]
	strH r1,[r0],#2				;post-inc by 2 after the store
	strH r1,[r0],#2
	strH r1,[r0],#2
	add r5,r5,#2
	and r5,r5,#0x0F
	cmp r0,r9
	blt loop_pinstripe_thirdQuarter

	;	the last quarter works differently. We'll need to use a different
	;	loop counter to get the last pinstripe
	mov r2,#SCREEN_WIDTH/4				;inner loop counter
	mov r3,#48							;outer loop counter

loop_pinstripe_lastQuarter:
	ldrH r1,[r4,r5]
	strH r1,[r0],#2
	strH r1,[r0],#2
	strH r1,[r0],#2
	strH r1,[r0],#2
	add r5,r5,#2
	and r5,r5,#0x0F
	subs r2,r2,#1
	bne loop_pinstripe_lastQuarter
		mov r5,#0				;reset the palette pointer
		mov r2,#SCREEN_WIDTH/4			;reset the inner loop counter
		subs r3,r3,#1				;decrement the outer loop counter
		bne loop_pinstripe_lastQuarter          ;if we're not done, keep going

forever:
	b forever					;end of program

palArray:	;GAME BOY ADVANCE USES 15-BIT COLOR. WE WON'T USE THE TOP BIT.

	.word 0x0000			;black
	.word 0b0000000000011111	;red
	.word 0b0000001111100000	;green
	.word 0b0111110000000000	;blue
	.word 0b0111110000011111	;magenta
	.word 0b0111111111100000	;cyan
	.word 0b0000001111111111	;yellow
	.word 0x7FFF			;white


<!-- Anything within these bracket tags is commented, single or multi-line. -->


# This is a comment

procedure x(y,z)    #: This is a comment and an IPL meta-comment for a procedure


; The following computes the factorial of a number "n"
fact = product(indgen( n )+1) ; where n should be an integer


[This is a single-line comment.]

[This is a
multi-line comment.]

[Comments can [be nested].]


h	:= A_ScreenHeight
w	:= A_ScreenWidth
pToken	:= gdip_Startup()
hdc	:= CreateCompatibleDC()
hbm	:= CreateDIBSection(w, h)
obm	:= SelectObject(hdc, hbm)
G	:= Gdip_GraphicsFromHDC(hdc)

OnExit, Exit

Gui -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui Show, NA
hwnd	:= WinExist()

colors	:= [0xFF000000, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF
	  , 0xFFFF00FF, 0xFF00FFFF, 0xFFFFFF00, 0xFFFFFFFF] ; ARGB
pBrush	:= []
Loop % colors.MaxIndex()
	pBrush[A_Index] := Gdip_BrushCreateSolid(colors[A_Index])
Loop 4
{
	n := A_Index
	Loop % w
		Gdip_FillRectangle(G, pBrush[Mod(A_Index-1, colors.MaxIndex())+1]
				    , A_Index*n-n, (n-1)*h/4, n, h/4)
}

UpdateLayeredWindow(hwnd, hdc, 0, 0, W, H)

Loop % colors.MaxIndex()
	Gdip_DeleteBrush(pBrush[A_Index])

SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Return

Esc::
Exit:
Gdip_Shutdown(pToken)
ExitApp


w = 640 : h = 480
graphsize w, h

dim k = {black, red, green, blue, purple, cyan, yellow, white}
h /= 4

for i = 1 to 4
    col = 0
    y = (i-1) * h
    for x = 1 to w step i
        if col mod 8 = 0 then col = 0
        colour k[col]
        rect (x, y, x + i, y + h)
        col += 1
    next x
next i


# Single-line comment

// Single-line comment

/* Multi-line
   comment */


theory Text
imports Main
begin

(* Top-level Isar comment. *)

end


NB. Text that follows 'NB.' has no effect on execution.

0 : 0
Multi-line comments may be placed in strings,
like this.
)

Note 'example'
Another way to record multi-line comments as text is to use 'Note', which is actually
a simple program that makes it clearer when defined text is used only to provide comment.
)

'A simple string which is not used is legal, and will be discarded'


      SW_MAXIMIZE = 3
      SYS "ShowWindow", @hwnd%, SW_MAXIMIZE
      VDU 26

      W% = @vdu%!208 * 2
      H% = @vdu%!212 / 2

      COLOUR 1,9
      COLOUR 2,10
      COLOUR 3,12
      COLOUR 4,13
      COLOUR 5,14
      COLOUR 6,11
      COLOUR 7,15

      Y% = H%*4
      FOR P% = 1 TO 4
        Y% -= H%
        FOR X% = 0 TO W% STEP 4*P%
          C% = (C% + 1) MOD 8
          GCOL C%
          RECTANGLE FILL X%, Y%, 2*P%, H%
        NEXT
      NEXT P%


#include<graphics.h>
#include<conio.h>

#define sections 4

int main()
{
	int d=DETECT,m,maxX,maxY,x,y,colour=0,increment=1;
	initgraph(&d,&m,"c:/turboc3/bgi");

	maxX = getmaxx();
	maxY = getmaxy();

	for(y=0;y<maxY;y+=maxY/sections)
	{
		for(x=0;x<maxX;x+=increment)
		{
			setfillstyle(SOLID_FILL,(colour++)%16);
			bar(x,y,x+increment,y+maxY/sections);
		}
		increment++;
		colour = 0;
	}

	getch();
	closegraph();
	return 0;
}


//* This is a comment line (//* in columns 1-3)


# this is a single line comment

(* this is a
multi-line comment *)


# this is a single line comment
"Hello #world" # the first # on this line is part of the jq program


#!/usr/bin/env/jsish
/* Comments, in Jsish */

// to end of line comment, double slash

/*
 Enclosed comment, slash star, ending with star slash
 Cannot be nested, but can cross line boundaries and occur
 pretty much anywhere whitespace is allowed
*/

var x = 'X'; /* A var called X */
/* active code on this line */ printf("Result %q %d\n", /* comment code mix */ x, /**/42);

;x;
// jsish also handles double slash commented
// unit test echo lines as a special case of "expect failure"

;//noname(x);

/*
=!EXPECTSTART!=
Result X 42
x ==> X
noname(x) ==>
PASS!: err = can not execute expression: 'noname' not a function
=!EXPECTEND!=
*/


# single line

#=
Multi-
line
comment
=#


  / this is a comment
  2+2  / as is this


(in-package :cg-user)

;;; We only need a bitmap pane - nothing fancy
(defclass draw-pane (bitmap-pane)())

;;; close it down by clicking on it
(defmethod mouse-left-down ((pane draw-pane) buttons data)
  (declare (ignore buttons data))
  (close pane))

;;; Create the window and draw the pinstripes
(defun make-draw-window ()
  (let ((win (make-window :one :class 'draw-pane :width 300 :height 200)))
    (draw win)))

;;; Function to draw the pinstripes.  The lines are a bit ragged at the intersections
;;; between pinstripe sections due to the fact that common graphics uses round line
;;; caps and there doesn't appear any way to change that.  Could be fixed by using
;;; rectangles rather than lines or, perhaps, by setting rectangular clipping regions.

(defun draw (win)
  (do ((lwidth 1 (+ 1 lwidth))
       (top 0 bottom)
       (colors (make-array 8 :initial-contents
                           '(black red green blue magenta cyan yellow white)))
       (bottom (/ (height win) 4) (+ (/ (height win) 4) bottom)))
      ((eql 5 lwidth) t)
    (with-line-width (win lwidth)
      (do ((xpos 0 (+ xpos lwidth))
           (clr-ndx 0 (mod (+ clr-ndx 1) 8)))
           ((> xpos (width win)) t)
        (with-foreground-color (win (aref colors clr-ndx))
          (draw-line win
                     (make-position xpos top)
                     (make-position xpos bottom)))))))


USING: accessors arrays colors.constants kernel locals math
math.ranges opengl sequences ui ui.gadgets ui.render ;

CONSTANT: palette
{
    COLOR: black
    COLOR: red
    COLOR: green
    COLOR: blue
    COLOR: magenta
    COLOR: cyan
    COLOR: yellow
    COLOR: white
}

CONSTANT: bands 4

TUPLE: pinstripe < gadget ;

: <pinstripe> ( -- pinstripe ) pinstripe new ;

M: pinstripe pref-dim* drop { 400 400 } ;

: set-color ( n -- ) palette length mod palette nth gl-color ;

:: draw-pinstripe ( pinstripe n -- )
    pinstripe dim>> first2 :> ( w h )
    h 4 /i :> quarter
    quarter n * :> y2
    y2 quarter - :> y1
    0 w n <range> [| x |
        x n / set-color x y1 2array x n + y2 2array gl-fill-rect
    ] each ;

M: pinstripe draw-gadget*
    bands [1,b] [ draw-pinstripe ] with each ;

<pinstripe> "Color pinstripe" open-window


' version 14-03-2017
'    compile with: fbc -s console
' or compile with: fbc -s gui

Dim As UInteger ps, col, h, w, x, y1, y2
ScreenInfo w, h

' create display size window, 8bit color (palette), no frame
ScreenRes w, h, 8,, 8

h = h \ 4 : y2 = h -1

For ps = 1 To 4
    col = 0
    For x = 0 To (w - ps -1) Step ps
        Line (x, y1) - (x + ps -1, y2), col, bf
        col = (col +1) And 255
    Next
    y1 += h : y2 += h
Next

' empty keyboard buffer
While Inkey <> "" : Wend
'Print : Print "hit any key to end program"
Sleep
End


//This is a comment.
//This is another comment.

/* This is a comment too. */

/* This is a
multi-line
comment */


// This is a single line comment

/*
    This is a
    multi-line
    comment
*/

/*
    Multi-line comments
    /*
        can also be nested
    */
    like so
*/

const val CURRENT_VERSION = "1.0.5-2"  // A comment can also be added at the end of a line
const val /* or even in the middle of a line */ NEXT_MAJOR_VERSION = "1.1"

/**
 * This is a documentation comment used by KDoc.
 *
 * It's documenting the main function which is the entry-point to a Kotlin executable.
 *
 * @param [args] A string array containing the command line arguments (if any) passed to the executable
 * @return Implicit return value is Unit which signifies no meaningful return value (like 'void' in java)
 */
fun main(args: Array<String>) {
    println("Current stable version is $CURRENT_VERSION")
    println("Next major version is $NEXT_MAJOR_VERSION")
}


;; this is a comment on a single line

°°°
this is
   a comment
     on several lines
°°°


'WARNING this takes a time to display

Public Sub Form_Open()
Dim iColour As Integer[] = [Color.Black, Color.red, Color.Green, Color.Magenta, Color.Cyan, Color.Yellow, Color.white]
Dim hPanel As Panel
Dim siCount, siCounter, siSet As Short

With Me
  .Arrangement = Arrange.Row
  .Border = False
  .Height = 1080
  .Width = 400
  .Fullscreen = True
End With

For siCounter = 1 To 4
  For siCount = 0 To Desktop.Width Step siCounter
    hpanel = New Panel(Me)
    hpanel.Width = siCounter
    hpanel.Height = Desktop.Height / 4
    HPanel.Background = iColour[siSet]
    Inc siSet
    If siSet > 6 Then siSet = 0
  Next
Next

End


package main

import "github.com/fogleman/gg"

var palette = [8]string{
    "000000", // black
    "FF0000", // red
    "00FF00", // green
    "0000FF", // blue
    "FF00FF", // magenta
    "00FFFF", // cyan
    "FFFF00", // yellow
    "FFFFFF", // white
}

func pinstripe(dc *gg.Context) {
    w := dc.Width()
    h := dc.Height() / 4
    for b := 1; b <= 4; b++ {
        for x, ci := 0, 0; x < w; x, ci = x+b, ci+1 {
            dc.SetHexColor(palette[ci%8])
            y := h * (b - 1)
            dc.DrawRectangle(float64(x), float64(y), float64(b), float64(h))
            dc.Fill()
        }
    }
}

func main() {
    dc := gg.NewContext(900, 600)
    pinstripe(dc)
    dc.SavePNG("color_pinstripe.png")
}


# single line comment starts with hash mark

/* inline or multi-line comment uses C-style syntax */


\documentclass{minimal}
\begin{document}
% This is a comment
\end{document}


link graphics,numbers,printf

procedure main()  # pinstripe

   &window := open("Colour Pinstripe","g","bg=black") |
      stop("Unable to open window")

   WAttrib("canvas=hidden")
   WAttrib(sprintf("size=%d,%d",WAttrib("displaywidth"),WAttrib("displayheight")))
   WAttrib("canvas=maximal")

   Colours := ["black", "red", "green", "blue", "magenta", "cyan", "yellow", "white"]
   height := WAttrib("height")
   width  := WAttrib("width")

   maxbands := 4                             # bands to draw
   bandheight := height / maxbands           # height of each band
   every bands := 1 to maxbands do {         # for each band
         top   := 1 + bandheight * (bands-1) # .. top of band
         every c := 1 to width do {
            colour := Colours[ceil((c+0.)/bands)%*Colours+1]
            if colour == "black" then next   # skip black
            else {
               Fg(colour)
               DrawLine(c,top,c,top+bandheight-1)
               }
         }
      }
   WDone()
end


   load 'viewmat'
   size=. 2{.".wd'qm' NB. J6
   size=. getscreenwh_jgtk_ '' NB. J7
   'rgb'viewmat (4<[email protected]%~{:size)# ({.size) $&> 1 2 3 4#&.> <256#.255*#:i.8


import java.awt.*;
import static java.awt.Color.*;
import javax.swing.*;

public class ColourPinstripeDisplay extends JPanel {
    final static Color[] palette = {black, red, green, blue, magenta,cyan,
        yellow, white};

    final int bands = 4;

    public ColourPinstripeDisplay() {
        setPreferredSize(new Dimension(900, 600));
    }

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        int h = getHeight();
        for (int b = 1; b <= bands; b++) {
            for (int x = 0, colIndex = 0; x < getWidth(); x += b, colIndex++) {
                g.setColor(palette[colIndex % palette.length]);
                g.fillRect(x, (b - 1) * (h / bands), x + b, b * (h / bands));
            }
        }
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setTitle("ColourPinstripeDisplay");
            f.add(new ColourPinstripeDisplay(), BorderLayout.CENTER);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        });
    }
}


'This is a comment
REM This is a comment

print "This has a comment on the end of the line." 'This is a comment
print "This also has a comment on the end of the line." : REM This is a comment


% This is a comment

%{ This is a comment
spanning several lines %}


-- This is a comment.
-- This is another comment


using Gtk, Graphics, Colors

function drawline(ctx, p1, p2, color, width)
    move_to(ctx, p1.x, p1.y)
    set_source(ctx, color)
    line_to(ctx, p2.x, p2.y)
    set_line_width(ctx, width)
    stroke(ctx)
end

const can = @GtkCanvas()
const win = GtkWindow(can, "Colour pinstripe/Display", 400, 400)
const colors = [colorant"black", colorant"red", colorant"green", colorant"blue",
          colorant"magenta", colorant"cyan", colorant"yellow", colorant"white"]
const numcolors = length(colors)

@guarded draw(can) do widget
    ctx = getgc(can)
    h = height(can)
    w = width(can)
    deltaw = 1.0
    for (i, x) in enumerate(0:deltaw:w)
        drawline(ctx, Point(x, 0.25*h), Point(x, 0), colors[i % numcolors + 1], deltaw)
    end
    for (i, x) in enumerate(0:deltaw*2:w)
        drawline(ctx, Point(x, 0.5*h), Point(x, 0.25*h), colors[i % numcolors + 1], deltaw*2)
    end
    for (i, x) in enumerate(0:deltaw*3:w)
        drawline(ctx, Point(x, 0.75*h), Point(x, 0.5*h), colors[i % numcolors + 1], deltaw*3)
    end
    for (i, x) in enumerate(0:deltaw*4:w)
        drawline(ctx, Point(x, h), Point(x, 0.75*h), colors[i % numcolors + 1], deltaw*4)
    end
end

show(can)
const cond = Condition()
endit(w) = notify(cond)
signal_connect(endit, win, :destroy)
wait(cond)


// version 1.1.0

import java.awt.*
import java.awt.Color.*
import javax.swing.*

class ColourPinstripeDisplay : JPanel() {
    private companion object {
        val palette = arrayOf(black, red, green, blue, magenta, cyan, yellow, white)
    }

    private val bands = 4

    init {
        preferredSize = Dimension(900, 600)
    }

    override fun paintComponent(g: Graphics) {
        super.paintComponent(g)
        for (b in 1..bands) {
            var colIndex = 0
            val h = height / bands
            for (x in 0 until width step b) {
                g.color = palette[colIndex % palette.size]
                g.fillRect(x, (b - 1) * h, b, h)
                colIndex++
            }
        }
    }
}

fun main(args: Array<String>) {
    SwingUtilities.invokeLater {
        val f = JFrame()
        f.defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        f.title = "ColourPinstripeDisplay"
        f.add(ColourPinstripeDisplay(), BorderLayout.CENTER)
        f.pack()
        f.setLocationRelativeTo(null)
        f.isVisible = true
    }
}


Module Checkit {
      Window 16, 14000,12000;
      Module Pinstripe {
            Smooth off  ' use of GDI32
            Dim colors(0 to 7)
            Colors(0)=#000000,#FF0000, #00FF00, #0000FF, #FF00FF, #00FFFF, #FFFF00, #FFFFFF
            pixelsX=scale.x/twipsX
            pixelsY=scale.y/twipsY
            zoneheight=scale.y/4
            n=0
            Refresh 5000
            For i=1 to 4 {
                  move 0, (i-1)*zoneheight
                  pinw=i*twipsx
                  For j=1 to pixelsX/i {
                        Fill pinw, zoneheight, color(n)
                        Step  0, -zoneheight
                        n++:if n=8 then n=0
                  }
            }
            \\ now we make the refersh
            Refresh 100
      }
      \\ draw to console window
      \\ now we make a window and draw there
      Pinstripe
      Layer 32 {
            Window 12, 10000,10000
            Pinstripe
            Show
      }
      Declare Pinstripe Form
      Layer Pinstripe {
            Window 12, 10000,10000
            Pinstripe
            motion 2000, 2000
      }
      refresh 20
            Thread {
                 if control$="MAIN" then if mouse then player 32,  mousea.x, mousea.y
            } as anyvar interval 100

      Method Pinstripe, "Show", 1
      Threads Erase
      Layer 32 {Hide}
      Cls
}
Checkit


colors := [yellow, black, red, green, magenta, cyan, white]:
plots:-display( [
    seq( plot([1+i/10,y,y=5..6], color=colors[i mod 7 + 1],thickness=1), i = 1..500),
    seq( plot([1+i/10,y,y=4..5], color=colors[i mod 7 + 1],thickness=2), i = 1..500),seq( plot([1+i/10,y,y=3..4], color=colors[i mod 7 + 1],thickness=3), i = 1..500),seq( plot([1+i/10,y,y=2..3], color=colors[i mod 7 + 1],thickness=4,size=[interface(screenwidth)*20,interface(screenheight)*32]), i = 1..500)],
axes=none);


-- comment may appear anywhere on line
// comment may appear anywhere on line
# comment may appear anywhere on line
/*  this is a
block comment that
may span any number of lines */


; comments come after a semicolon, and last until the end of the line


% single-line comment; extends to the end of the line


import gintro/[glib, gobject, gtk, gio, cairo]

const
  Width = 420
  Height = 420

const Colors = [[0.0, 0.0, 0.0], [255.0, 0.0, 0.0],
                [0.0, 255.0, 0.0], [0.0, 0.0, 255.0],
                [255.0, 0.0, 255.0], [0.0, 255.0, 255.0],
                [255.0, 255.0, 0.0], [255.0, 255.0, 255.0]]

#---------------------------------------------------------------------------------------------------

proc draw(area: DrawingArea; context: Context) =
  ## Draw the color bars.

  const lineHeight = Height div 4

  var y = 0.0
  for lineWidth in [1.0, 2.0, 3.0, 4.0]:
    context.setLineWidth(lineWidth)
    var x = 0.0
    var colorIndex = 0
    while x < Width:
      context.setSource(Colors[colorIndex])
      context.moveTo(x, y)
      context.lineTo(x, y + lineHeight)
      context.stroke()
      colorIndex = (colorIndex + 1) mod Colors.len
      x += lineWidth
    y += lineHeight

#---------------------------------------------------------------------------------------------------

proc onDraw(area: DrawingArea; context: Context; data: pointer): bool =
  ## Callback to draw/redraw the drawing area contents.

  area.draw(context)
  result = true

#---------------------------------------------------------------------------------------------------

proc activate(app: Application) =
  ## Activate the application.

  let window = app.newApplicationWindow()
  window.setSizeRequest(Width, Height)
  window.setTitle("Color pinstripe")

  # Create the drawing area.
  let area = newDrawingArea()
  window.add(area)

  # Connect the "draw" event to the callback to draw the color bars.
  discard area.connect("draw", ondraw, pointer(nil))

  window.showAll()

#———————————————————————————————————————————————————————————————————————————————————————————————————

let app = newApplication(Application, "Rosetta.ColorPinstripe")
discard app.connect("activate", activate)
discard app.run()


open Graphics

let () =
  open_graph "";
  let width = size_x ()
  and height = size_y () in
  let colors = [| black; red; green; blue; magenta; cyan; yellow; white |] in
  let num_colors = Array.length colors in
  let h = height / 4 in
  for i = 1 to 4 do
    let j = 4 - i in
    for x = 0 to pred width do
      set_color colors.((x / i) mod num_colors);
      moveto x (j * h); lineto x (j * h + h);
    done
  done;
  ignore(read_key())


* Ceci est un commentaire qui prend fin quand la ligne se termine

(* Ceci est un commentaire sur plusieurs lignes
comme vous pouvez le voir puisqu'il s'étend sur
plusieurs lignes justement... *)

(* Cette exemple est selon la revision LSE-2000 *)


# single line comment (space after # is required)


#!/usr/bin/perl -w
use strict ;
use GD ;

my $image = new GD::Image( 320 , 240 ) ;
my %colors = ( "white" => [ 255 , 255 , 255 ] , "red" => [255 , 0 , 0 ] ,
      "green" => [ 0 , 255 , 0 ] , "blue" => [ 0 , 0 , 255 ] ,
      "magenta" => [ 255 , 0 , 255 ] , "yellow" => [ 255 , 255 , 0 ] ,
      "cyan" => [ 0 , 255 , 255 ] , "black" => [ 0 , 0 , 0 ] ) ;
my @paintcolors ;
foreach my $color ( keys %colors ) {
   my $paintcolor = $image->colorAllocate( @{$colors{ $color }} ) ;
   push @paintcolors, $paintcolor ;
}
my $startx = 0 ;
my $starty = 0 ;
my $run = 0 ;
my $barheight = 240 / 4 ;
my $colorindex = 0 ;
while ( $run < 4 ) {
   my $barwidth =  $run + 1 ;
   while ( $startx + $barwidth < 320 ) {
      $image->filledRectangle( $startx , $starty , $startx + $barwidth ,
	    $starty + $barheight - 1 , $paintcolors[ $colorindex % 8 ] ) ;
      $startx += $barwidth ;
      $colorindex++ ;
   }
   $starty += $barheight ;
   $startx = 0 ;
   $colorindex = 0 ;
   $run++ ;
 }
open ( DISPLAY , ">" , "pinstripes.png" ) || die ;
binmode DISPLAY ;
print DISPLAY $image->png ;
close DISPLAY ;


-- A single line comment

--[[A multi-line
    comment --]]


Module Comments {
      Print "ok" ' comment at the end of line
      Print "ok"  \ comment at the end of line
      \ comment  in one line - different color with previous two
      'comment in one line
      Rem : Print "ok"   ' statements after Rem skipped, but stay with syntax highlight
}
Comments


eval(2*3)  # eval(2*3)  "#" and text after it aren't processed but passed along

dnl  this text completely disappears, including the new line

divert(-1)
Everything diverted to -1 is processed but the output is discarded.
A comment could take this form as long as no macro names are used.
divert


x := 4: x; # Everything on this line, after this, is a comment.

17; (* This
   is
   a multiline comment *) 23.4;


--
-- demo\rosetta\Colour_pinstripe.exw
-- =================================
--
with javascript_semantics -- but not yet CD_PRINTER
include pGUI.e

constant colours = {CD_BLACK, CD_RED, CD_GREEN, CD_MAGENTA, CD_CYAN, CD_YELLOW, CD_WHITE}
--constant colours = {CD_BLACK, CD_WHITE}

procedure draw_to(cdCanvas cdcanvas)
    cdCanvasActivate(cdcanvas)
    integer {width, height} = cdCanvasGetSize(cdcanvas)
    for y=1 to 4 do
        integer x = 0, c = 1, h = floor(height/(5-y))
        while x<width do
            cdCanvasSetForeground(cdcanvas, colours[c])
            cdCanvasBox(cdcanvas, x, x+y, height-h, height)
            x += y
            c = iff(c=length(colours)?1:c+1)
        end while
        height -= h
    end for
    cdCanvasFlush(cdcanvas)
end procedure

Ihandle dlg, canvas
cdCanvas cddbuffer, cdcanvas

function redraw_cb(Ihandle /*ih*/)
    draw_to(cddbuffer)
    return IUP_DEFAULT
end function

function map_cb(Ihandle ih)
    cdcanvas = cdCreateCanvas(CD_IUP, ih)
    cddbuffer = cdCreateCanvas(CD_DBUFFER, cdcanvas)
    return IUP_DEFAULT
end function

function unmap_cb(Ihandle /*ih*/)
    cdKillCanvas(cddbuffer)
    cdKillCanvas(cdcanvas)
    return IUP_DEFAULT
end function

function print_cb(Ihandle /*ih*/)
    if platform()!=JS then
        cdCanvan print_canvas = cdCreateCanvas(CD_PRINTER, "pinstripe -d")
        if print_canvas!=NULL then
            draw_to(print_canvas)
            cdKillCanvas(print_canvas)
        end if
    end if
    return IUP_DEFAULT
end function

function exit_cb(Ihandle /*ih*/)
    return IUP_CLOSE
end function

procedure main()
    IupOpen()

    Ihandle file_menu = IupMenu({IupMenuItem("&Print",Icallback("print_cb")),
                                 IupMenuItem("E&xit", Icallback("exit_cb"))})

    Ihandle main_menu = IupMenu({IupSubmenu("File", file_menu)})

    canvas = IupCanvas(NULL)
    IupSetAttribute(canvas, "RASTERSIZE", "600x400") -- initial size

    IupSetCallback(canvas, "MAP_CB",    Icallback("map_cb"))
    IupSetCallback(canvas, "UNMAP_CB",  Icallback("unmap_cb"))

    dlg = IupDialog(canvas)
    IupSetAttribute(dlg, "TITLE", "Colour pinstripe")
    IupSetAttributeHandle(dlg,"MENU",main_menu)
    IupSetCallback(canvas, "ACTION", Icallback("redraw_cb"))
    IupShowXY(dlg,IUP_CENTER,IUP_CENTER)
    IupSetAttribute(canvas, "RASTERSIZE", NULL) -- release the minimum limitation
    if platform()!=JS then
        IupMainLoop()
        IupClose()
    end if
end procedure

main()


%This is a comment
%% Two percent signs and a space are called a cell divider


-- Two dashes precede a single line comment

/* This is a
   multi-line comment */


! A pling in a line starts a comment

INT   n:=5   ! Comments can appear at the end of a line

/* A comment block can also be defined using climbstar and starclimb symbols.
  This allows comments to be stretched across several lines */


(de *Colors  # Black Red Green Blue Magenta Cyan Yellow White
   ((0 0 0) (255 0 0) (0 255 0) (0 0 255)
      (255 0 255) (0 255   255) (255 255 0) (255 255 255) .) )

(let Ppm  # Create PPM of 384 x 288 pixels
   (make
      (for N 4
         (let L
            (make
               (do (/ 384 N)
                  (let C (pop *Colors)
                     (do N (link C)) ) ) )
            (do 72 (link L)) ) ) )
   (out '(display)  # Pipe to ImageMagick
      (prinl "P6")  # NetPBM format
      (prinl (length (car Ppm)) " " (length Ppm))
      (prinl 255)
      (for Y Ppm (for X Y (apply wr X))) ) )


To run:
Start up.
Clear the screen.
Imagine a box with the screen's left and the screen's top and the screen's right and the screen's bottom divided by 4.
Make a color pinstripe given 1 pixel and the box.
Draw the color pinstripe.
Draw the next color pinstripe given the color pinstripe.
Draw the next color pinstripe given the color pinstripe.
Draw the next color pinstripe given the color pinstripe.
Refresh the screen.
Wait for the escape key.
Shut down.

A color pinstripe has a width and a box.

To make a color pinstripe given a width and a box:
Put the width into the color pinstripe's width.
Put the box into the color pinstripe's box.

To draw a color pinstripe:
Put the color pinstripe's box into a bound box.
Put the color pinstripe's width into a width.
Imagine a box with the bound's left and the bound's top and the width and the bound's bottom.
Put the bound's right divided by the width into an amount.
Loop.
If a counter is past the amount, exit.
Draw and fill the box with the black color. Move the box right the width.
Draw and fill the box with the red color. Move the box right the width.
Draw and fill the box with the green color. Move the box right the width.
Draw and fill the box with the blue color. Move the box right the width.
Draw and fill the box with the magenta color. Move the box right the width.
Draw and fill the box with the cyan color. Move the box right the width.
Draw and fill the box with the yellow color. Move the box right the width.
Draw and fill the box with the white color.
Repeat.

To draw the next color pinstripe given a color pinstripe:
Add 1 pixel to the color pinstripe's width.
Move the color pinstripe's box down the color pinstripe's box's height.
Draw the color pinstripe.


;Create a Pinstripe image with a pattern of vertical stripe colors
Procedure PinstripeDisplay(width, height, Array psColors(1), numColors = 0)
  Protected x, imgID, psHeight = height / 4, psWidth = 1, psTop, horzBand, curColor

  If numColors < 1: numColors = ArraySize(psColors()) + 1: EndIf

  imgID = CreateImage(#PB_Any, width, height)
  If imgID
    StartDrawing(ImageOutput(imgID))
      Repeat
        x = 0
        curColor = 0
        Repeat
          Box(x, psTop, psWidth, psHeight, psColors(curColor))
          curColor = (curColor + 1) % numColors
          x + psWidth
        Until x >= width
        psWidth + 1
        horzBand + 1
        psTop = horzBand * height / 4  ;move to the top of next horizontal band of image
      Until psTop >= height
    StopDrawing()
  EndIf
  ProcedureReturn imgID
EndProcedure

;Open a window and display the pinstripe
If OpenWindow(0, 0, 0, 1, 1,"PureBasic Pinstripe", #PB_Window_Maximize | #PB_Window_SystemMenu)
  Dim psColors(7)
  psColors(0) = RGB($00, $00, $00) ;black
  psColors(1) = RGB($FF, $00, $00) ;red
  psColors(2) = RGB($00, $FF, $00) ;green
  psColors(3) = RGB($00, $00, $FF) ;blue
  psColors(4) = RGB($FF, $00, $FF) ;magenta
  psColors(5) = RGB($00, $FF, $FF) ;cyan
  psColors(6) = RGB($FF, $FF, $00) ;yellow
  psColors(7) = RGB($FF, $FF, $FF) ;white

  PicID = PinstripeDisplay(WindowWidth(0), WindowHeight(0), psColors())
  ImageGadget(0, 0, 0, WindowWidth(0), WindowHeight(0), ImageID(PicID))
  While WaitWindowEvent() <> #PB_Event_CloseWindow
  Wend
EndIf


' This is a comment
i = i + 1  ' You can also append comments to statements


; this is a comment
1 1 + ; add one and one together


puts 'code' # I am a comment
/* This is
 * a multiple
 * line comment */


;Single Line Comment
/*
Multiple
Line
Comment
*/


(* Comments (* can nest *)
   and they can span multiple lines.
 *)


from turtle import *

colors = ["black", "red", "green", "blue", "magenta", "cyan", "yellow", "white"]

# Middle of screen is 0,0

screen = getscreen()

left_edge = -screen.window_width()//2

right_edge = screen.window_width()//2

quarter_height = screen.window_height()//4

half_height = quarter_height * 2

speed("fastest")

for quarter in range(4):
    pensize(quarter+1)
    colornum = 0

    min_y = half_height - ((quarter + 1) * quarter_height)
    max_y = half_height - ((quarter) * quarter_height)

    for x in range(left_edge,right_edge,quarter+1):
        penup()
        pencolor(colors[colornum])
        colornum = (colornum + 1) % len(colors)
        setposition(x,min_y)
        pendown()
        setposition(x,max_y)

notused = input("Hit enter to continue: ")


SCREEN 12
w = 640: h = 480

h = h / 4
y2 = h - 1

FOR i = 1 TO 4
    col = 0
    y = (i - 1) * h
    FOR x = 1 TO w STEP i
        IF col MOD 15 = 0 THEN col = 0
        LINE (x, y)-(x + i, y + h), col, BF
        col = col + 1
    NEXT x
NEXT i


#lang racket/gui

(define-values [W H] (get-display-size #t))

(define parts 4)
(define colors
  '("Black" "Red" "Green" "Blue" "Magenta" "Cyan" "Yellow" "White"))

(define (paint-pinstripe canvas dc)
  (send dc set-pen "black" 0 'transparent)
  (send dc set-brush "black" 'solid)
  (define H* (round (/ H parts)))
  (for ([row parts])
    (define Y (* row H*))
    (for ([X (in-range 0 W (add1 row))] [c (in-cycle colors)])
      (send dc set-brush c 'solid)
      (send dc draw-rectangle X Y (add1 row) H*))))

(define full-frame%
  (class frame%
    (define/override (on-subwindow-char r e)
      (when (eq? 'escape (send e get-key-code))
        (send this show #f)))
    (super-new
     [label "Color Pinstripe"] [width W] [height H]
     [style '(no-caption no-resize-border hide-menu-bar no-system-menu)])
    (define c (new canvas% [parent this] [paint-callback paint-pinstripe]))
    (send this show #t)))

(void (new full-frame%))


# This comment goes to the end of the line
/** This comment is multi-line.
    Yes, it starts with a two stars
    and ends with only one.
    These should only be used for docstrings. */


/# This is a comment #/
/#
comments can span multiple lines
nested comments are not supported #/


"String literals are technically the only long-term comment format";
// Some compilers will, however, compile // one-liners to string literals as well (and vice-versa)
/* Classical C-style comments are removed entirely during compile */


// this is a comment
// this is also a comment


my ($x,$y) = 1280, 720;

my @colors = map -> $r, $g, $b { [$r, $g, $b] },
     0,   0,   0,
   255,   0,   0,
     0, 255,   0,
     0,   0, 255,
   255,   0, 255,
     0, 255, 255,
   255, 255,   0,
   255, 255, 255;

my $img = open "pinstripes.ppm", :w orelse die "Can't create pinstripes.ppm: $_";

$img.print: qq:to/EOH/;
    P3
    # pinstripes.ppm
    $x $y
    255
    EOH

my $vzones = $y div 4;
for 1..4 -> $width {
    my $stripes = ceiling $x / $width / +@colors;
    my $row = [flat ((@colors Xxx $width) xx $stripes).map: *.values].splice(0,$x);
    $img.put: $row for ^$vzones;
}

$img.close;


# Project : Colour pinstripe/Display

load "guilib.ring"

paint = null

new qapp
        {
        win1 = new qwidget() {
                  setwindowtitle("archimedean spiral")
                  setgeometry(100,100,500,600)
                  label1 = new qlabel(win1) {
                              setgeometry(10,10,400,400)
                              settext("")
                  }
                  new qpushbutton(win1) {
                          setgeometry(150,500,100,30)
                          settext("draw")
                          setclickevent("draw()")
                  }
                  show()
        }
        exec()
        }

func draw
        p1 = new qpicture()
               color = new qcolor() {
               setrgb(0,0,255,255)
        }
        pen = new qpen() {
                 setcolor(color)
                 setwidth(1)
        }
        paint = new qpainter() {
                  begin(p1)
                  setpen(pen)
        w = 100
        h = 100
        color = list(8)
        color[1] = [0 ,0, 0]
        color[2] = [255, 0, 0]
        color[3] = [0, 255, 0]
        color[4] = [0, 0, 255]
        color[5] = [255, 0, 255]
        color[6] = [0, 255, 255]
        color[7] = [255, 255, 0]
        color[8] = [255, 255, 255]
        y = h*4
        for p = 1 to 4
             y = y - h
             for x = 0 to w step 4*p
                  col = random(7) + 1
                  color2 = new qcolor()
                  color2.setrgb(color[col][1],color[col][2],color[col][3],255)
                  mybrush = new qbrush() {setstyle(1) setcolor(color2)}
                  setbrush(mybrush)
                  paint.drawrect(x, y, 2*p, h)
             next
        next
        endpaint()
        }
        label1 { setpicture(p1) show() }


import java.awt.Color._
import java.awt._

import javax.swing._

object ColourPinstripeDisplay extends App {
  private def palette = Seq(black, red, green, blue, magenta, cyan, yellow, white)

  SwingUtilities.invokeLater(() =>
    new JFrame("Colour Pinstripe") {

      class ColourPinstripe_Display extends JPanel {

        override def paintComponent(g: Graphics): Unit = {
          val bands = 4

          super.paintComponent(g)
          for (b <- 1 to bands) {
            var colIndex = 0
            for (x <- 0 until getWidth by b) {
              g.setColor(ColourPinstripeDisplay.palette(colIndex % ColourPinstripeDisplay.palette.length))
              g.fillRect(x, (b - 1) * (getHeight / bands), x + b, b * (getHeight / bands))
              colIndex += 1
            }
          }
        }

        setPreferredSize(new Dimension(900, 600))
      }

      add(new ColourPinstripe_Display, BorderLayout.CENTER)
      pack()
      setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
      setLocationRelativeTo(null)
      setVisible(true)
    }
  )

}


* This is a comment and extends to the end of the line


// Single line comment, of course!

/*
Multi line comment!
*/

/**
Documentation block
<doc>can include XML parsed nodes between doc tags</doc>
**/


// This comment goes up to the end of the line
/* This
is
a
multiline
comment */


/*

 NetRexx comment block

*/

-- NetRexx line comment


require('GD')

func pinstripes(width = 1280, height = 720) {

    var im = %O<GD::Image>.new(width, height)
    var colors = [0, 255].variations_with_repetition(3)

    var paintcolors = colors.shuffle.map {|rgb|
        im.colorAllocate(rgb...)
    }

    var starty     = 0
    var barheight  = height//4

    for barwidth in (1..4) {
        for (
            var(startx = 0, colorindex = 0);
            startx + barwidth <= width;
            startx += barwidth
        ) {
            im.filledRectangle(startx, starty, startx+barwidth,
                starty + barheight - 1, paintcolors[colorindex++ % 8])
        }
        starty += barheight
    }

    return im
}

File('pinstripes.png').write(pinstripes().png, :raw)


FOR I=1 TO 4
 COLIDX=0
 YTOP=(I-1)*60
 FOR X=0 TO 399 STEP I
  IF COLIDX MOD 8==0 THEN
   RESTORE @COLOURS
  ENDIF
  READ R,G,B
  GFILL X,YTOP,X+I,YTOP+59,RGB(R,G,B)
  INC COLIDX
 NEXT
NEXT

@COLOURS
DATA 0,0,0
DATA 255,0,0
DATA 0,255,0
DATA 0,0,255
DATA 255,0,255
DATA 0,255,255
DATA 255,255,0
DATA 255,255,255


package require Tcl 8.5
package require Tk 8.5

wm attributes . -fullscreen 1
pack [canvas .c -highlightthick 0] -fill both -expand 1
set colors {black red green blue magenta cyan yellow white}

set dy [expr {[winfo screenheight .c]/4}]
set y 0
foreach dx {1 2 3 4} {
    for {set x 0} {$x < [winfo screenwidth .c]} {incr x $dx} {
	.c create rectangle $x $y [expr {$x+$dx}] [expr {$y+$dy}] \
            -fill [lindex $colors 0] -outline {}
	set colors [list {*}[lrange $colors 1 end] [lindex $colors 0]]
    }
    incr y $dy
}


# Nim supports single-line comments

var x = 0 ## Documentation comments start with double hash characters.

var y = 0 ## Documentation comments are a proper part of the syntax (they're not discarded by parser, and a real part of AST).

#[
There are also multi-line comments
Everything inside of #[]# is commented.
]#

# You can also discard multiline statements:

discard """This can be considered as a "comment" too
This is multi-line"""


# This comment goes up to the end of the line
/* This
is
a
multiline
comment */


# This is a comment that goes from the # to the end of the line.
; This is a comment that goes from the ; to the end of the

/* This is a
multi-line
comment */


(* this is a comment *)
(*
   and this is a
   multiline comment
   (* with a nested comment *)
*)


LET w = 640
LET h = 480
SET WINDOW 0, w, 0, h

LET h = h/4
LET y2 = h-1

FOR i = 1 TO 4
    LET col = 0
    LET y = (i-1)*h
    FOR x = 1 TO w STEP i
        IF remainder(col,15) = 0 THEN LET col = 0
        SET COLOR col
        BOX AREA x, x+i, y, y+h
        LET col = col+1
    NEXT x
NEXT i
END


Public Class Main
    Inherits System.Windows.Forms.Form
    Public Sub New()
        Me.FormBorderStyle = FormBorderStyle.None
        Me.WindowState = FormWindowState.Maximized
    End Sub
    Private Sub Main_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim Index As Integer
        Dim Colors() As Color = {Color.Black, Color.Red, Color.Green, Color.Magenta, Color.Cyan, Color.Yellow, Color.White}
        Dim Height = (Me.ClientSize.Height / 4) + 1
        For y = 1 To 4
            Dim Top = Me.ClientSize.Height / 4 * (y - 1)
            For x = 0 To Me.ClientSize.Width Step y
                If Index = 6 Then Index = 0 Else Index += 1
                Me.Controls.Add(New Panel With {.Top = Top, .Height = Height, .Left = x, .Width = y, .BackColor = Colors(Index)})
            Next
        Next
    End Sub
End Class


#This is a comment.
# This is other comment.

#~ This is a comment too. ~#

#~ This is a
multi-line
comment ~#


(* This a comment
   (* containing nested comment *)
 *)

(** This an OCamldoc documentation comment *)


# I am a comment till the end of line
% I am a comment till the end of line

%{
  This comment spans
  multiple lines
%}


import "graphics" for Canvas, Color
import "dome" for Window

class Game {
    static init() {
        Window.title = "Color pinstripe"
        __width = 900
        __height = 600
        Canvas.resize(__width, __height)
        Window.resize(__width, __height)
        var colors = [
            Color.hex("000000"), // black
            Color.hex("FF0000"), // red
            Color.hex("00FF00"), // green
            Color.hex("0000FF"), // blue
            Color.hex("FF00FF"), // magenta
            Color.hex("00FFFF"), // cyan
            Color.hex("FFFF00"), // yellow
            Color.hex("FFFFFF")  // white
        ]
        pinstripe(colors)
    }

    static pinstripe(colors) {
        var w = __width
        var h = (__height/4).floor
        for (b in 1..4) {
            var x = 0
            var ci = 0
            while (x < w) {
                var y = h * (b - 1)
                Canvas.rectfill(x, y, b, h, colors[ci%8])
                x = x + b
                ci = ci + 1
            }
        }
    }

    static update() {}

    static draw(dt) {}
}


code ChIn=7, Point=41, SetVid=45;
int X, Y, W, C;
[SetVid($13);                   \set 320x200 graphics mode in 256 colors
for Y:= 0 to 200-1 do           \for all the scan lines...
    [W:= Y/50 + 1;              \width of stripe = 1, 2, 3, 4
    C:= 0;                      \set color to black so first pixel becomes blue
    for X:= 0 to 320-1 do       \for all the pixels on a scan line...
        [if rem(X/W) = 0 then C:= C+1;  \cycle through all system colors
        Point(X, Y, C);         \set pixel at X,Y to color C
        ];
    ];
X:= ChIn(1);                    \wait for keystroke
SetVid(3);                      \restore normal text mode display
]


/*
  Multi-line comment block
 */

-- this type of comment works in ooRexx, NetRexx and some of the more popular REXX implementations like Regina

hour = 0  -- which is, like midnight, dude.

hour = 12 /* time for lunch! works as well (and really everywhere) */


// This is a single line comment

/*
  This comment spans
  multiple lines
*/


'  Basic line comment
;  Assembly code line comment
// C line comment
/* C block comment */


% one line comment

%% often with double "%" because then the indentation is correct in Emacs

/* multi line
   comment
*/


(* This is a comment.
   It may extend across multiple lines. *)

{ Alternatively curly braces
  can be used. }

(* This is a valid comment in Standard Pascal,
   but not valid in [[Turbo Pascal]]. }

{ The same is true in this case *)


F quibble(words)
   R S words.len
      0
         ‘{}’
      1
         ‘{’words[0]‘}’
      E
         ‘{’words[0.<(len)-1].join(‘, ’)‘ and ’words.last‘}’

print(quibble([‘’] * 0))
print(quibble([‘ABC’]))
print(quibble([‘ABC’, ‘DEF’]))
print(quibble([‘ABC’, ‘DEF’, ‘G’, ‘H’]))


w = 640 : h = 480
open window w, h
h4 = h/4

FOR I=1 TO 4
    COLIDX=0
    YTOP=(I-1)*h4
    FOR X=1 TO w STEP I
        IF mod(COLIDX, 8) = 0 RESTORE COLOURS
        READ R,G,B
        color R, G, B
        fill rectangle X,YTOP,X+I,YTOP+h4
        COLIDX = COLIDX + 1
    NEXT
NEXT

label COLOURS
DATA 0,0,0
DATA 255,0,0
DATA 0,255,0
DATA 0,0,255
DATA 255,0,255
DATA 0,255,255
DATA 255,255,0
DATA 255,255,255


# This is a comment
print "Hello\n"    # This is also a comment
end


*        Comma quibbling           13/03/2017
COMMAQUI CSECT
         USING  COMMAQUI,R13       base register
         B      72(R15)            skip savearea
         DC     17F'0'             savearea
         STM    R14,R12,12(R13)    save previous context
         ST     R13,4(R15)         link backward
         ST     R15,8(R13)         link forward
         LR     R13,R15            set addressability
         LA     R6,1               i=1
       DO WHILE=(C,R6,LE,=A(N))    do i=1 to hbound(t)
         LR     R1,R6                i
         SLA    R1,5                 *32
         LA     R2,T-32              @t(0)
         AR     R1,R2                @t(i)
         MVC    S1,0(R1)             s1=t(i)
         MVC    S2,=CL32'{'          s2='{'
         LA     R8,S2+1              s2ins=1
         MVC    I2,=F'0'             i2=0
         LA     R7,1                 j=1
       DO WHILE=(C,R7,LE,=A(L'T))    do j=1 to length(t)
         LA     R1,S1                  @s1
         BCTR   R1,0                   @s1-1
         AR     R1,R7                  @s1-1+j
         MVC    CJ,0(R1)               cj=mid(s1,j,1)
         CLI    CJ,C' '                if cj=' '
         BE     EXITJ                  then goto exitj
       IF CLI,CJ,EQ,C',' THEN          if cj="," then
         MVC    0(2,R8),=C', '           s2=s2||", "
         LA     R8,2(R8)                 s2ins=s2ins+2
         LR     R0,R8                    s2ins
         LA     R1,S2+1                  @s2+1
         SR     R0,R1                    len(s2)-1
         ST     R0,I2                    i2=len(s2)-1
       ELSE     ,                      else
         MVC    0(1,R8),CJ               s2=s2||cj
         LA     R8,1(R8)                 s2ins=s2ins+1
       ENDIF    ,                      endif
         LA     R7,1(R7)               j++
       ENDDO    ,                    enddo j
EXITJ    MVI    0(R8),C'}'           s2=s2||"}"
         LA     R8,1(R8)             s2ins=s2ins+1
         L      R0,I2                i2
       IF LTR,R0,NZ,R0 THEN          if i2<>0 then
         MVC    S2B,S2                 s2b=mid(s2,1,i2-1)
         LA     R1,S2B-1               @s2b-1
         A      R1,I2                  +i2
         MVC    0(5,R1),=C' and '      s2b||" and "
         LA     R1,5(R1)               +5
         LA     R2,S2+1                @s2+1
         A      R2,I2                  +i2
         LR     R3,R8                  s2ins
         LA     R0,S2+1                @s2+1
         SR     R3,R0                  s2ins-(@s2+1)
         S      R3,I2                  -i2
         BCTR   R3,0                   -1
         EX     R3,XMVC                s2b||=mid(s2,i2+2)
         MVC    S2,S2B     s2=mid(s2,1,i2-1)||" and "||mid(s2,i2+2)
       ENDIF    ,                    endif
         XPRNT  S2,L'S2              print s2
         LA     R6,1(R6)             i++
       ENDDO    ,                  enddo i
         L      R13,4(0,R13)       restore previous savearea pointer
         LM     R14,R12,12(R13)    restore previous context
         XR     R15,R15            rc=0
         BR     R14                exit
XMVC     MVC    0(0,R1),0(R2)      mvc @r1,@r2
N        EQU    (TEND-T)/L'T       items of t
T        DC     CL32' ',CL32'ABC',CL32'ABC,DEF',CL32'ABC,DEF,G,H'
TEND     DS     0C
I2       DS     F
S1       DS     CL(L'T)
S2       DS     CL(L'T)
S2B      DS     CL(L'T)
CJ       DS     CL1
         YREGS
         END    COMMAQUI


		org	100h
		jmp	demo
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;; Given a list of strings in HL, and a pointer in DE, write
		;; the resulting string starting at DE.
quibble:	mvi	a,'{'		; Write the first {,
		stax	d
		inx 	d		; And increment the pointer
		push	h		; Keep start of list
		call	strseqlen	; Get length of list
		pop	h		; Restore start of list
		xra	a		; Is the list empty?
		ora	b
		jz	quibend		; If empty list, we're done.
quibcopy:	call	strcpy		; Copy current string into output
		inx	h		; Advance input pointer to next string
		dcr	b		; Decrement counter
		jz	quibend		; If zero, that was the last string
		push	h		; Push input pointer
		mov	a,b		; Is the counter 1 now?
		cpi	1
		lxi	h,quibcomma 	; Add a comma and space,
		jnz	quibsep		; unless the counter was 1,
		lxi	h,quiband	; then use " and "
quibsep:	call	strcpy		; Copy the separator into the output
		pop	h		; Restore the input pointer
		jmp	quibcopy	; Do the next string in the list
quibend:	mvi	a,'}'		; Write the final '}'
		stax	d
		inx	d
		mvi	a,'$'		; And write a string terminator
		stax 	d
		ret
quibcomma:	db	', $'
quiband:	db	' and $'
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;; Copy the string under HL to DE until the terminator $.
		;; The terminator is not copied; HL and DE are left one byte
		;; beyond the last byte copied.
strcpy:		mov	a,m		; Get byte from input
		cpi	'$'		; Are we at the end?
		rz			; Then stop.
		stax	d		; Otherwise, store byte at output
		inx	h		; Increment the pointers
		inx	d
		jmp	strcpy		; Copy next byte.
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;; Return in B the amount of strings in the string list in HL
strseqlen:	mvi	a,'$'		; String end
		mvi	b,0		; String counter
count:		cmp 	m		; Empty string?
		rz			; Then we're done
		inr	b		; Otherwise, we have a string
strsrch:	cmp	m		; Find the end of the string
		inx 	h
		jnz	strsrch
		jmp	count
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;; Demo code: run 'quibble' on the examples
demo:		mvi	c,4		; Four examples
		lxi	h,examples	; Pointer to first example
example:	push	b		; Push example count
		lxi	d,buffer	; Into the buffer,
		call	quibble		; write the output of comma-quibbling
		inx	h		; Point to next example
		push	h		; Save pointer to next example
		lxi	d,buffer	; Write the output to the console
		mvi	c,9
		call	5
		lxi	d,newline	; Write a newline to the console
		mvi	c,9
		call	5
		pop	h		; Restore example pointer
		pop	b		; Restore example counter
		dcr	c		; If not zero,
		jnz 	example		; do the next example.
		ret
newline:	db	10,13,'$'
examples:	db	'$'
		db	'ABC$$'
		db	'ABC$DEF$$'
		db	'ABC$DEF$G$H$$'
buffer:


# this is commented
// this is commented


/*
 * Multi-line comment
 */

% Single-line Prolog-style comment


# The rest of the line is ignored
#{
   This is a
   multiline comment
}#
NIL
Immediately stop reading this file. Because all text in the input file following
a top-level 'NIL' is ignored.

This is typically used conditionally, with a read-macro expression like
`*Dbg
so that this text is only read if in debugging mode.


// This is a comment.
/* This is a
   multi
   line
   comment */

int e = 3; // end-of-statement comment.


DEFINE PTR="CARD"

PROC Append(CHAR ARRAY text,suffix)
  BYTE POINTER srcPtr,dstPtr
  BYTE len

  len=suffix(0)
  IF text(0)+len>255 THEN
    len=255-text(0)
  FI
  IF len THEN
    srcPtr=suffix+1
    dstPtr=text+text(0)+1
    MoveBlock(dstPtr,srcPtr,len)
    text(0)==+suffix(0)
  FI
RETURN

PROC Quibble(PTR ARRAY items INT count CHAR ARRAY result)
  INT i

  result(0)=0
  Append(result,"(")
  FOR i=0 TO count-1
  DO
    Append(result,items(i))
    IF i=count-2 THEN
      Append(result," and ")
    ELSEIF i<count-2 THEN
      Append(result,", ")
    FI
  OD
  Append(result,")")
RETURN

PROC Test(PTR ARRAY items BYTE count)
  CHAR ARRAY result(256)

  Quibble(items,count,result)
  PrintE(result)
RETURN

PROC Main()
  PTR ARRAY items(5)

  Test(items,0)

  items(0)="ABC"
  Test(items,1)

  items(1)="DEF"
  Test(items,2)

  items(2)="G"
  Test(items,3)

  items(3)="H"
  Test(items,4)
RETURN


with Ada.Text_IO, Ada.Command_Line; use Ada.Command_Line;

procedure Comma_Quibble is

begin
   case Argument_Count is
      when 0 => Ada.Text_IO.Put_Line("{}");
      when 1 => Ada.Text_IO.Put_Line("{" & Argument(1) & "}");
      when others =>
	 Ada.Text_IO.Put("{");
	 for I in 1 .. Argument_Count-2 loop
	    Ada.Text_IO.Put(Argument(I) & ", ");
	 end loop;
	 Ada.Text_IO.Put(Argument(Argument_Count-1) & " and " &
		         Argument(Argument_Count) & "}");
   end case;
end Comma_Quibble;


\A comment like this lasts until the end of the line
Put 1 plus [there are inline comments too] 1 into a number.


# returns a string ( assumed to be of space-separated words ) with the words  #
# separated by ", ", except for the last which is separated from the rest by  #
# " and ". The list is enclosed by braces                                     #
PROC to list = ( STRING words ) STRING:
    BEGIN
        # count the number of words                                           #
        INT  word count := 0;
        BOOL in word    := FALSE;
        FOR char pos FROM LWB words TO UPB words
        DO
            IF NOT is upper( words[ char pos ] )
            THEN
                # not an upper-case letter, possibly a word has been ended    #
                in word := FALSE
            ELSE
                # not a delimitor, possibly the start of a word               #
                IF NOT in word
                THEN
                    # we are starting a new word                              #
                    word count +:= 1;
                    in word     := TRUE
                FI
            FI
        OD;

        # format the result                                                   #
        STRING result    := "{";
        in word          := FALSE;
        INT  word number := 0;
        FOR char pos FROM LWB words TO UPB words
        DO
            IF NOT is upper( words[ char pos ] )
            THEN
                # not an upper-case letter, possibly a word has been ended    #
                in word := FALSE
            ELSE
                # not a delimitor, possibly the start of a word               #
                IF NOT in word
                THEN
                    # we are starting a new word                              #
                    word number +:= 1;
                    in word      := TRUE;
                    IF word number > 1
                    THEN
                        # second or subsequent word - need a separator        #
                        result +:= IF word number = word count
                                   THEN # final word                          #
                                       " and "
                                   ELSE # non-final word                      #
                                       ", "
                                   FI
                    FI
                FI;
                # add the character to the result                             #
                result +:= words[ char pos ]
            FI
        OD;

        result + "}"
    END # to list # ;

    # procedure to test the to list PROC                                      #
    PROC test to list = ( STRING words ) VOID:
        print( ( ( words
                 + ": "
                 + to list( words )
                 )
               , newline
               )
             );

    # test the to list PROC                                                   #
    test to list( "" );
    test to list( "ABC" );
    test to list( "ABC DEF" );
    test to list( "ABC DEF G H" )


// a single-line comment

/* a multi-line
   comment
*/

/*
 * a multi-line comment
 * with some decorative stars
 */

// comment out a code line
// println("foo");

// comment at the end of a line
println("foo bar"); // "baz"


% this is a single-line comment that extends to the end of the line


;comments come after an unquoted semicolon and last until the end of the line
foo = 5 ;This is a comment
c$ = ";This is not a comment"  ;This is also a comment


begin

    % returns a list of the words contained in wordString, separated by ", ", %
    % except for the last which is separated from the rest by " and ".        %
    % The words are enclosed by braces                                        %
    string(256) procedure toList ( string(256) value  words ) ;
    begin
        string(256) list;
        integer     wordCount, wordNumber, listPos;
        logical     inWord;

        % returns true if ch is an upper-case letter, false otherwise         %
        %         assumes the letters are consecutive in the character set    %
        %         (as in ascii) would not be correct if the character set was %
        %         ebcdic (as in the original implementations of Algol W)      %
        logical procedure isUpper ( string(1) value ch ) ; ch >= "A" and ch <= "Z" ;

        % adds a character to the result                                      %
        procedure addChar( string(1) value ch ) ;
        begin
            list( listPos // 1 ) := ch;
            listPos := listPos + 1;
        end addChar ;

        % adds a string to the result                                        %
        procedure addString( string(256) value str
                           ; integer     value len
                           ) ;
            for strPos := 0 until len - 1 do addChar( str( strPos // 1 ) );

        % count the number of words                                           %

        wordCount := 0;
        inWord    := false;
        for charPos := 0 until 255
        do begin
            if isUpper( words( charPos // 1 ) ) then begin
                % not an upper-case letter, possibly a word has been ended    %
                inWord := false
                end
            else begin
                % not a delimitor, possibly the start of a word               %
                if not inWord then begin
                    % we are starting a new word                              %
                    wordCount := wordCount + 1;
                    inWord    := true
                end if_not_inWord
            end
        end for_charPos;

        % format the result                                                   %

        list       := "";
        listPos    := 0;
        inWord     := false;
        wordNumber := 0;

        addChar( "{" );

        for charPos := 0 until 255
        do begin
            if not isUpper( words( charPos // 1 ) ) then begin
                % not an upper-case letter, possibly a word has been ended    %
                inWord := false
                end
            else begin
                % not a delimitor, possibly the start of a word               %
                if not inWord then begin
                    % we are starting a new word                              %
                    wordNumber := wordNumber + 1;
                    inWord     := true;
                    if wordNumber > 1 then begin
                        % second or subsequent word - need a separator        %
                        if wordNumber = wordCount then addString( " and ", 5 ) % final word %
                                                  else addString( ", ",    2 ) % non-final word %
                    end
                end;
                % add the character to the result                             %
                addChar( words( charPos // 1 ) )
            end
        end for_charPos ;

        addChar( "}" );

        list
    end toList ;

    % procedure to test the toList procedure                                 %
    procedure testToList ( string(256) value words ) ;
    begin
        string(256) list;
        list := toList( words );
        write( s_w := 0
             , words( 0 // 32 )
             , ": "
             , list(  0 // 32 )
             )
    end testToList ;

    % test the toList procedure                                              %
    testToList( "" );
    testToList( "ABC" );
    testToList( "ABC DEF" );
    testToList( "ABC DEF G H" );

end.


-- quibble :: [String] -> String
on quibble(xs)
    if length of xs > 1 then
        set applyCommas to ¬
            compose([curry(my intercalate)'s |λ|(", "), my |reverse|, my tail])

        intercalate(" and ", ap({applyCommas, my head}, {|reverse|(xs)}))
    else
        concat(xs)
    end if
end quibble

-- TEST -----------------------------------------------------------------------
on run
    script braces
        on |λ|(x)
            "{" & x & "}"
        end |λ|
    end script

    unlines(map(compose({braces, quibble}), ¬
        append({{}, {"ABC"}, {"ABC", "DEF"}, {"ABC", "DEF", "G", "H"}}, ¬
            map(|words|, ¬
                {"One two three four", "Me myself I", "Jack Jill", "Loner"}))))
end run

-- GENERIC FUNCTIONS ----------------------------------------------------------

-- A list of functions applied to a list of arguments
-- (<*> | ap) :: [(a -> b)] -> [a] -> [b]
on ap(fs, xs)
    set {intFs, intXs} to {length of fs, length of xs}
    set lst to {}
    repeat with i from 1 to intFs
        tell mReturn(item i of fs)
            repeat with j from 1 to intXs
                set end of lst to |λ|(contents of (item j of xs))
            end repeat
        end tell
    end repeat
    return lst
end ap

-- (++) :: [a] -> [a] -> [a]
on append(xs, ys)
    xs & ys
end append

-- compose :: [(a -> a)] -> (a -> a)
on compose(fs)
    script
        on |λ|(x)
            script
                on |λ|(a, f)
                    mReturn(f)'s |λ|(a)
                end |λ|
            end script

            foldr(result, x, fs)
        end |λ|
    end script
end compose

-- concat :: [[a]] -> [a] | [String] -> String
on concat(xs)
    script append
        on |λ|(a, b)
            a & b
        end |λ|
    end script

    if length of xs > 0 and class of (item 1 of xs) is string then
        set unit to ""
    else
        set unit to {}
    end if
    foldl(append, unit, xs)
end concat

-- curry :: (Script|Handler) -> Script
on curry(f)
    script
        on |λ|(a)
            script
                on |λ|(b)
                    |λ|(a, b) of mReturn(f)
                end |λ|
            end script
        end |λ|
    end script
end curry

-- foldl :: (a -> b -> a) -> a -> [b] -> a
on foldl(f, startValue, xs)
    tell mReturn(f)
        set v to startValue
        set lng to length of xs
        repeat with i from 1 to lng
            set v to |λ|(v, item i of xs, i, xs)
        end repeat
        return v
    end tell
end foldl

-- foldr :: (a -> b -> a) -> a -> [b] -> a
on foldr(f, startValue, xs)
    tell mReturn(f)
        set v to startValue
        set lng to length of xs
        repeat with i from lng to 1 by -1
            set v to |λ|(v, item i of xs, i, xs)
        end repeat
        return v
    end tell
end foldr

-- head :: [a] -> a
on head(xs)
    if length of xs > 0 then
        item 1 of xs
    else
        missing value
    end if
end head

-- intercalate :: Text -> [Text] -> Text
on intercalate(strText, lstText)
    set {dlm, my text item delimiters} to {my text item delimiters, strText}
    set strJoined to lstText as text
    set my text item delimiters to dlm
    return strJoined
end intercalate

-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
    tell mReturn(f)
        set lng to length of xs
        set lst to {}
        repeat with i from 1 to lng
            set end of lst to |λ|(item i of xs, i, xs)
        end repeat
        return lst
    end tell
end map

-- Lift 2nd class handler function into 1st class script wrapper
-- mReturn :: Handler -> Script
on mReturn(f)
    if class of f is script then
        f
    else
        script
            property |λ| : f
        end script
    end if
end mReturn

-- |reverse| :: [a] -> [a]
on |reverse|(xs)
    if class of xs is text then
        (reverse of characters of xs) as text
    else
        reverse of xs
    end if
end |reverse|

-- tail :: [a] -> [a]
on tail(xs)
    if length of xs > 1 then
        items 2 thru -1 of xs
    else
        {}
    end if
end tail

-- unlines :: [String] -> String
on unlines(xs)
    intercalate(linefeed, xs)
end unlines

-- words :: String -> [String]
on |words|(s)
    words of s
end |words|


# This is a comment
foo = 5 # You can also append comments to statements


 ( The word "(" is a compiler directive (a builder,
   in Quackery jargon) that causes the compiler to
   disregard everything until it encounters a ")"
   preceded by whitespace.

   If you require more than that, it is trivial to
   define new comment builders...                  )

  [ behead carriage = until ] builds #

  # Now the word "#" will cause the compiler to
  # disregard everything from the "#" to the end of
  # the line that it occurs on.

  [ drop $ "" ] builds commentary

  commentary

  The word "commentary" will cause the compiler to
  disregard everything that comes after it to the
  end of the source string or file.


REM This is a remark...
' This is also a remark...

IF a = 0 THEN REM (REM follows syntax rules)
IF a = 0 THEN '(apostrophe doesn't follow syntax rules, so use END IF after this)
END IF

'Metacommands such as $DYNAMIC and $INCLUDE use the REM (or apostrophe).
REM $STATIC 'arrays cannot be resized once dimensioned.
REM $DYNAMIC 'enables resizing of array dimensions with REDIM.
REM $INCLUDE: 'loads a reference file or library.


; this is a to-end-of-line coment

#| balanced comment, #| can be nested |# |#

#;(this expression is ignored)

#; ; the following expression is commented because of the #; in the beginning
(ignored)


quibble: function [seq][
	if? 0=size seq -> "{}"
	else [
		if? 1=size seq -> "{" ++ seq\0 ++ "}"
		else -> "{" ++ (join.with:", " slice seq 0 (size seq)-1) ++ " and " ++ (last seq) ++ "}"
	]
]

sentences: [
	[]
	["ABC"]
	["ABC" "DEF"]
	["ABC" "DEF" "G" "H"]
]

loop sentences 'sentence [
	print quibble sentence
]


fun quibble(s):
    let result = s.join(' and ').replace(|| and ||, ", ", length(s) - 1)
    return "{ $result }"

let s = [
    []
    ["ABC"]
    ["ABC", "DEF"]
    ["ABC", "DEF", "G", "H"]
]

for i in s:
    print(quibble i)


; This is a line comment.

{ Multi-line strings can
  be used as comments
  if you like }


// This is a valid comment
// A space is needed after the double slash


( comments are placed between parentheses. A space must follow the opening parenthesis. )


MsgBox % quibble([])
MsgBox % quibble(["ABC"])
MsgBox % quibble(["ABC", "DEF"])
MsgBox % quibble(["ABC", "DEF", "G", "H"])

quibble(d) {
	s:=""
	for i, e in d
	{
		if (i<d.MaxIndex()-1)
			s:= s . e . ", "
		else if (i=d.MaxIndex()-1)
			s:= s . e . " and "
		else
			s:= s . e
	}
	return "{" . s . "}"
}


function quibble(a, n,    i, s) {
	for (i = 1; i < n - 1; i++) s = s a[i] ", "
	i = n - 1; if (i > 0) s = s a[i] " and "
	if (n > 0) s = s a[n]
	return "{" s "}"
}

BEGIN {
	print quibble(a, 0)
	n = split("ABC", b); print quibble(b, n)
	n = split("ABC DEF", c); print quibble(c, n)
	n = split("ABC DEF G H", d); print quibble(d, n)
}


/*REXX program that demonstrates what happens when dividing by zero.  */
y=7
say 44 / (7-y)      /* divide by some strange thingy.*/


//this is a single line comment
#this also a single line comment!


x = "code" # I am a comment
x = "code" // Here I comment thee
#  matlab-like document line
// C++ like document line


. "This is a comment line"

. "Print Hello world"
* "Hello world."

. "This is the only way to comment a line in Robotic"


x = "code" # I am a comment

=begin hello
I a POD documentation comment like Perl
=end puts "code"


'This is a comment
REM This is a comment

print "Notice comment at  the end of the line."          'This is a comment
print "Also notice this comment at the end of the line." : REM This is a comment


@echo off
setlocal enabledelayedexpansion

::THE MAIN THING...
echo.
set inp=[]
call :quibble
set inp=["ABC"]
call :quibble
set inp=["ABC","DEF"]
call :quibble
set inp=["ABC","DEF","G","H"]
call :quibble
echo.
pause
exit /b
::/THE MAIN THING...

::THE FUNCTION
:quibble
set cont=0
set proc=%inp:[=%
set proc=%proc:]=%

for %%x in (%proc%) do (
	set /a cont+=1
	set x=%%x
	set str!cont!=!x:"=!
)
set /a bef=%cont%-1
set output=%str1%
if %cont%==2 (set output=%str1% and %str2%)
if %cont% gtr 2 (
	for /l %%y in (2,1,%bef%) do (
		set output=!output!^, !str%%y!
	)
	set output=!output! and !str%cont%!
)
echo {!output!}
goto :EOF
::/THE FUNCTION


get "libhdr"

// Add a character to the end of a string
let addch(s, ch) be
$(  s%0 := s%0 + 1
    s%(s%0) := ch
$)
// Add s2 to the end of s1
and adds(s1, s2) be
    for i = 1 to s2%0 do
        addch(s1, s2%i)

// Comma quibbling on strs, which should be a 0-terminated
// vector of string pointers.
let quibble(strs, buf) = valof
$(  buf%0 := 0
    addch(buf, '{')
    until !strs = 0 do
    $(  addch(buf, '"')
        adds(buf, !strs)
        addch(buf, '"')
        unless strs!1 = 0
            test strs!2 = 0
                then adds(buf, " and ")
                else adds(buf, ", ")
        strs := strs + 1
    $)
    addch(buf, '}')
    resultis buf
$)

let start() be
$(  let words = vec 4
    let buf = vec 63

    words!0 := 0
    writef("%S*N", quibble(words, buf))

    words!0 := "ABC" ; words!1 := 0
    writef("%S*N", quibble(words, buf))

    words!1 := "DEF" ; words!2 := 0
    writef("%S*N", quibble(words, buf))

    words!2 := "G" ; words!3 := "H" ; words!4 := 0
    writef("%S*N", quibble(words, buf))
$)


// A single line comment

/*
    This is a multi-line (aka block) comment

    /*
        containing nested multi-line comment
        (nesting supported since 0.9-pre https://github.com/mozilla/rust/issues/9468)
    */
*/

/// Outer single line Rustdoc comments apply to the next item.

/**
    Outer multi-line Rustdoc comments.

 *  Leading asterisk (*) in multi-line Rustdoc comments
 *  is not considered to be part of the comment text,
 *  blanks and tabs preceding the initial asterisk (*) are also stripped.
*/

fn example() {

    //! Inner single line Rustdoc comments apply to their enclosing item.

    /*!
        Inner multi-line Rustdoc comments.
        See also https://github.com/mozilla/rust/wiki/Doc-using-rustdoc
    */
}

#[doc = "Unsugared outer Rustdoc comments.
        (outer attributes are not terminated by a semi-colon)"]
fn example() {
    #[doc = "Unsugared inner Rustdoc comments.
            (inner attributes are terminated by a semi-colon)
            See also https://github.com/mozilla/rust/blob/master/doc/rust.md#attributes"];
}


/* comment */

*another comment;

* both
  may
  be
  multiline;


// A single line comment

/* A multi-line
   comment */


; Basically the same as Common Lisp
; While R5RS does not provide block comments, they are defined in SRFI-30, as in Common Lisp :

#| comment
... #| nested comment
... |#
|#

; See http://srfi.schemers.org/srfi-30/srfi-30.html


// this is a comment
i=i+1 // this is a comment


( :?L1
& ABC:?L2
& ABC DEF:?L3
& ABC DEF G H:?L4
& L1 L2 L3 L4:?names
& ( quibble
  =   w
    .     !arg:%?w (% %:?arg)
        & !w ", " quibble$!arg
      | !arg:%?w %?arg&!w " and " quibble$!arg
      | !arg
  )
& (concat=.str$("{" quibble$!arg "}"))
&   whl
  ' (!names:%?name ?names&out$(!name concat$!!name))
);


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *quib(const char **strs, size_t size)
{

    size_t len = 3 + ((size > 1) ? (2 * size + 1) : 0);
    size_t i;

    for (i = 0; i < size; i++)
        len += strlen(strs[i]);

    char *s = malloc(len * sizeof(*s));
    if (!s)
    {
        perror("Can't allocate memory!\n");
        exit(EXIT_FAILURE);
    }

    strcpy(s, "{");
    switch (size) {
        case 0:  break;
        case 1:  strcat(s, strs[0]);
                 break;
        default: for (i = 0; i < size - 1; i++)
                 {
                     strcat(s, strs[i]);
                     if (i < size - 2)
                         strcat(s, ", ");
                     else
                         strcat(s, " and ");
                 }
                 strcat(s, strs[i]);
                 break;
    }
    strcat(s, "}");
    return s;
}

int main(void)
{
    const char *test[] = {"ABC", "DEF", "G", "H"};
    char *s;

    for (size_t i = 0; i < 5; i++)
    {
        s = quib(test, i);
        printf("%s\n", s);
        free(s);
    }
    return EXIT_SUCCESS;
}


# A single line comment

(* A multi-line
    comment *)

(* In Seed7,
(* comments can be nested. *) *)


#   Hashtag is a comment
--  Dash dash is another comment
//  Slash slash is yet another comment
—   Alt/Option + Underscore creates an m-dash comment
(*  Parentheses and star is used for commenting
blocks of code (* and can be nested *) *)
set foo to true // all comments can append to statements


> Comments start where a > (greater than symbol) starts
set a 0 > Comments may start after a Set command


print("This is not a comment"); -- This is a comment
$ For nostalgic reasons, this is also a comment.


using System;
using System.Linq;

namespace CommaQuibbling
{
    internal static class Program
    {
        #region Static Members
	private static string Quibble(string[] input)
	{
            return
                String.Format("{{{0}}}",
                    String.Join("",
                        input.Reverse().Zip(
                            new [] { "", " and " }.Concat(Enumerable.Repeat(", ", int.MaxValue)),
                            (x, y) => x + y).Reverse()));
	}

        private static void Main()
        {
            Console.WriteLine( Quibble( new string[] {} ) );
            Console.WriteLine( Quibble( new[] {"ABC"} ) );
            Console.WriteLine( Quibble( new[] {"ABC", "DEF"} ) );
            Console.WriteLine( Quibble( new[] {"ABC", "DEF", "G", "H"} ) );

            Console.WriteLine( "< Press Any Key >" );
            Console.ReadKey();
        }

        #endregion
    }
}


COMMENT This is a comment for Simula 67;


"Comments traditionally are in double quotes."
"Multiline comments are also supported.
 Comments are saved as metadata along with the source to a method.
 A comment just after a method signature is often given to explain the
 usage of the method. The class browser may display such comments
 specially."


'Single line comments are preceded by a single quote or the command REM

PRINT "Hello" 'Single line comments may follow code

PRINT "Hello" REM You can also use the command REM following code

/*
Multi-line comments
are surrounded by
mirrored slash
and asterisk
*/

/*Multi-line comments do not have to actually have multiple lines*/

/* Spaces before or after comment bounds are optional.*/

/* A comment can also follow another comment */  'Like this

Some programmers like to do this to allow for /* Procedural comments */ followed by 'Programmer's notes.


#include <iostream>

template<class T>
void quibble(std::ostream& o, T i, T e) {
  o << "{";
  if (e != i) {
    T n = i++;
    const char* more = "";
    while (e != i) {
      o << more << *n;
      more = ", ";
      n = i++;
    }
    o << (*more?" and ":"") << *n;
  }
  o << "}";
}

int main(int argc, char** argv) {
  char const* a[] = {"ABC","DEF","G","H"};
  for (int i=0; i<5; i++) {
    quibble(std::cout, a, a+i);
    std::cout << std::endl;
  }
  return 0;
}


(defn quibble [sq]
  (let [sep (if (pos? (count sq)) " and " "")]
    (apply str
      (concat "{" (interpose ", " (butlast sq)) [sep (last sq)] "}"))))

; Or, using clojure.pprint's cl-format, which implements common lisp's format:
(defn quibble-f [& args]
  (clojure.pprint/cl-format nil "{~{~a~#[~; and ~:;, ~]~}}" args))

(def test
  #(doseq [sq [[]
               ["ABC"]
               ["ABC", "DEF"]
               ["ABC", "DEF", "G", "H"]]]
     ((comp println %) sq)))

(test quibble)
(test quibble-f)


* An asterisk in column 1 is the standard Snobol comment
* mechanism, marking the entire line as a comment. There
* are no block or multiline comments.

*               Comments may begin at
*               any position on the line.

- A hyphen in column 1 begins a control statement.
- Unrecognized control statements are ignored and
- may also mark comment lines. Not recommended.

                   ;* The semicolon statement separator
    output = 'FOO' ;* begins a new statement. This idiom
    output = 'BAR' ;* simulates an asterisk in the first
                   ;* column, allowing end of line comments.

END

Any text after the required END label is ignored.


'This is single-line comment

''This is
multiline comment''


SELECT * FROM mytable -- Selects all columns and rows


//this is a single line comment

#this is also a single line comment

/*
    this is a multi-line comment
*/


quibble = proc (words: array[string]) returns (string)
    out: string := "{"
    last: int := array[string]$high(words)

    for i: int in array[string]$indexes(words) do
        out := out || words[i]
        if i < last-1 then
            out := out || ", "
        elseif i = last-1 then
            out := out || " and "
        end
    end
    return(out || "}")
end quibble

start_up = proc ()
    as = array[string]
    aas = array[as]
    po: stream := stream$primary_output()

    testcases: aas := aas$
        [as$[],
         as$["ABC"],
         as$["ABC","DEF"],
         as$["ABC","DEF","G","H"]]

    for testcase: as in aas$elements(testcases) do
        stream$putl(po, quibble(testcase))
    end
end start_up


       >>SOURCE FORMAT IS FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. comma-quibbling-test.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
    FUNCTION comma-quibbling
    .
DATA DIVISION.
WORKING-STORAGE SECTION.
01  strs-area.
    03  strs-len                  PIC 9.
    03  strs                      PIC X(5)
                                  OCCURS 0 TO 9 TIMES
                                  DEPENDING ON strs-len.

PROCEDURE DIVISION.
    MOVE "ABC" TO strs (1)
    MOVE "DEF" TO strs (2)
    MOVE "G" TO strs (3)
    MOVE "H" TO strs (4)

    PERFORM VARYING strs-len FROM 0 BY 1 UNTIL strs-len > 4
        DISPLAY FUNCTION comma-quibbling(strs-area)
    END-PERFORM
    .
END PROGRAM comma-quibbling-test.

IDENTIFICATION DIVISION.
FUNCTION-ID. comma-quibbling.

DATA DIVISION.
LOCAL-STORAGE SECTION.
01  i                             PIC 9.

01  num-extra-words               PIC 9.

LINKAGE SECTION.
01  strs-area.
    03  strs-len                  PIC 9.
    03  strs                      PIC X(5)
                                  OCCURS 0 TO 9 TIMES
                                  DEPENDING ON strs-len.

01  str                           PIC X(50).

PROCEDURE DIVISION USING strs-area RETURNING str.
    EVALUATE strs-len
        WHEN ZERO
            MOVE "{}" TO str
            GOBACK

        WHEN 1
            MOVE FUNCTION CONCATENATE("{", FUNCTION TRIM(strs (1)), "}")
                TO str
            GOBACK
    END-EVALUATE

    MOVE FUNCTION CONCATENATE(FUNCTION TRIM(strs (strs-len - 1)),
        " and ", FUNCTION TRIM(strs (strs-len)), "}")
        TO str

    IF strs-len > 2
        SUBTRACT 2 FROM strs-len GIVING num-extra-words
        PERFORM VARYING i FROM num-extra-words BY -1 UNTIL i = 0
            MOVE FUNCTION CONCATENATE(FUNCTION TRIM(strs (i)), ", ", str)
                TO str
        END-PERFORM
    END-IF

    MOVE FUNCTION CONCATENATE("{", str) TO str
    .
END FUNCTION comma-quibbling.


(* This a comment
   (* containing nested comment *)
 *)


* Line comment: must be used at the beginning of a line (does not work in Mata)

// Line comment until the end of the line

/* Multiline comment

*/


// this is a single line comment
/* This a block comment
   /* containing nested comment */
 */

///This is a documentation comment

/**
  This is a documentation block comment
*/