import java.util.List;

public class ShoelaceFormula {
    private static class Point {
        int x, y;

        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return String.format("(%d, %d)", x, y);
        }
    }

    private static double shoelaceArea(List<Point> v) {
        int n = v.size();
        double a = 0.0;
        for (int i = 0; i < n - 1; i++) {
            a += v.get(i).x * v.get(i + 1).y - v.get(i + 1).x * v.get(i).y;
        }
        return Math.abs(a + v.get(n - 1).x * v.get(0).y - v.get(0).x * v.get(n - 1).y) / 2.0;
    }

    public static void main(String[] args) {
        List<Point> v = List.of(
            new Point(3, 4),
            new Point(5, 11),
            new Point(12, 8),
            new Point(9, 5),
            new Point(5, 6)
        );
        double area = shoelaceArea(v);
        System.out.printf("Given a polygon with vertices %s,%n", v);
        System.out.printf("its area is %f,%n", area);
    }
}


(() => {
    "use strict";

    // ------- SHOELACE FORMULA FOR POLYGONAL AREA -------

    // shoelaceArea :: [(Float, Float)] -> Float
    const shoeLaceArea = vertices => abs(
        uncurry(subtract)(
            ap(zip)(compose(tail, cycle))(
                vertices
            )
            .reduce(
                (a, x) => [0, 1].map(b => {
                    const n = Number(b);

                    return a[n] + (
                        x[0][n] * x[1][Number(!b)]
                    );
                }),
                [0, 0]
            )
        )
    ) / 2;

    // ----------------------- TEST -----------------------
    const main = () => {
        const ps = [
            [3, 4],
            [5, 11],
            [12, 8],
            [9, 5],
            [5, 6]
        ];

        return [
                "Polygonal area by shoelace formula:",
                `${JSON.stringify(ps)} -> ${shoeLaceArea(ps)}`
            ]
            .join("\n");
    };

    // ---------------- GENERIC FUNCTIONS -----------------

    // abs :: Num -> Num
    const abs = x =>
        // Absolute value of a given number
        // without the sign.
        0 > x ? -x : x;

    // ap :: (a -> b -> c) -> (a -> b) -> (a -> c)
    const ap = f =>
        // Applicative instance for functions.
        // f(x) applied to g(x).
        g => x => f(x)(
            g(x)
        );

    // compose (<<<) :: (b -> c) -> (a -> b) -> a -> c
    const compose = (...fs) =>
        // A function defined by the right-to-left
        // composition of all the functions in fs.
        fs.reduce(
            (f, g) => x => f(g(x)),
            x => x
        );

    // cycle :: [a] -> Generator [a]
    const cycle = function* (xs) {
        // An infinite repetition of xs,
        // from which an arbitrary prefix
        // may be taken.
        const lng = xs.length;
        let i = 0;

        while (true) {
            yield xs[i];
            i = (1 + i) % lng;
        }
    };

    // length :: [a] -> Int
    const length = xs =>
        // Returns Infinity over objects without finite
        // length. This enables zip and zipWith to choose
        // the shorter argument when one is non-finite,
        // like cycle, repeat etc
        "GeneratorFunction" !== xs.constructor
        .constructor.name ? (
            xs.length
        ) : Infinity;

    // subtract :: Num -> Num -> Num
    const subtract = x =>
        y => y - x;

    // tail :: [a] -> [a]
    const tail = xs =>
        // A new list consisting of all
        // items of xs except the first.
        "GeneratorFunction" !== xs.constructor
        .constructor.name ? (
            Boolean(xs.length) ? (
                xs.slice(1)
            ) : undefined
        ) : (take(1)(xs), xs);

    // take :: Int -> [a] -> [a]
    // take :: Int -> String -> String
    const take = n =>
        // The first n elements of a list,
        // string of characters, or stream.
        xs => "GeneratorFunction" !== xs
        .constructor.constructor.name ? (
            xs.slice(0, n)
        ) : Array.from({
            length: n
        }, () => {
            const x = xs.next();

            return x.done ? [] : [x.value];
        }).flat();

    // uncurry :: (a -> b -> c) -> ((a, b) -> c)
    const uncurry = f =>
        // A function over a pair, derived
        // from a curried function.
        (...args) => {
            const [x, y] = Boolean(args.length % 2) ? (
                args[0]
            ) : args;

            return f(x)(y);
        };

    // zip :: [a] -> [b] -> [(a, b)]
    const zip = xs => ys => {
        const
            n = Math.min(length(xs), length(ys)),
            vs = take(n)(ys);

        return take(n)(xs)
            .map((x, i) => [x, vs[i]]);
    };

    // MAIN ---
    return main();
})();


"""
Assumes x,y points go around the polygon in one direction.
"""
shoelacearea(x, y) =
    abs(sum(i * j for (i, j) in zip(x, append!(y[2:end], y[1]))) -
        sum(i * j for (i, j) in zip(append!(x[2:end], x[1]), y))) / 2

x, y = [3, 5, 12, 9, 5], [4, 11, 8, 5, 6]
@show x y shoelacearea(x, y)


// version 1.1.3

class Point(val x: Int, val y: Int) {
    override fun toString() = "($x, $y)"
}

fun shoelaceArea(v: List<Point>): Double {
    val n = v.size
    var a = 0.0
    for (i in 0 until n - 1) {
        a += v[i].x * v[i + 1].y - v[i + 1].x * v[i].y
    }
    return Math.abs(a + v[n - 1].x * v[0].y - v[0].x * v[n -1].y) / 2.0
}

fun main(args: Array<String>) {
    val v = listOf(
        Point(3, 4), Point(5, 11), Point(12, 8), Point(9, 5), Point(5, 6)
    )
    val area = shoelaceArea(v)
    println("Given a polygon with vertices at $v,")
    println("its area is $area")
}


{def shoelace
 {lambda {:pol}
  {abs
   {/
    {-
     {+ {S.map {{lambda {:pol :i} {* {car {A.get :i :pol}}
                                     {cdr {A.get {+ :i 1} :pol}}}} :pol}
               {S.serie 0 {- {A.length :pol} 2}}}
                                  {* {car {A.get {- {A.length :pol} 1} :pol}}
                                     {cdr {A.get 0 :pol}}}}
     {+ {S.map {{lambda {:pol :i} {* {car {A.get {+ :i 1} :pol}}
                                     {cdr {A.get :i :pol}}}} :pol}
               {S.serie 0 {- {A.length :pol} 2}}}
                                  {* {car {A.get 0 :pol}}
                                     {cdr {A.get {- {A.length :pol} 1} :pol}}}}} 2}}}}
-> shoelace

{def pol
  {A.new {cons 3 4}
         {cons 5 11}
         {cons 12 8}
         {cons 9 5}
         {cons 5 6}}}
-> pol = [(3 4),(5 11),(12 8),(9 5),(5 6)]

{shoelace {pol}}
-> 30


function shoeArea(ps)
  local function det2(i,j)
    return ps[i][1]*ps[j][2]-ps[j][1]*ps[i][2]
  end
  local sum = #ps>2 and det2(#ps,1) or 0
  for i=1,#ps-1 do sum = sum + det2(i,i+1)end
  return math.abs(0.5 * sum)
end


with(ArrayTools):

module Point()
 option object;
 local x := 0;
 local y := 0;

 export getX::static := proc(self::Point, $)
  return self:-x;
 end proc;

 export getY::static := proc(self::Point, $)
  return self:-y
 end proc;

 export ModuleApply::static := proc()
  Object(Point, _passed);
 end proc;

 export ModuleCopy::static := proc(new::Point, proto::Point, X, Y, $)
  new:-x := X;
  new:-y := Y;
 end proc;

 export ModulePrint::static := proc(self::Point)
  return cat("(", self:-x, ",", self:-y, ")");
 end proc;
end module:

module Polygon()
 option object;
 local vertices := Array([Point(0,0)]);

 export getVertices::static := proc(self::Polygon)
  return self:-vertices;
 end proc;

 export area::static := proc(self::Polygon)
  local i, N := ArrayNumElems(self:-vertices);
  local total := getX(self:-vertices[N]) * getY(self:-vertices[1]) - getX(self:-vertices[1]) * getY(self:-vertices[N]);
  total += map(`+`, seq(getX(self:-vertices[i]) * getY(self:-vertices[i+1]), i = 1..(N-1))) - map(`+`, seq(getX(self:-vertices[i+1]) * getY(self:-vertices[i]), i = 1..(N-1)));
  return abs(total / 2);
 end proc;

 export ModuleApply::static := proc()
  Object(Polygon, _passed);
 end proc;

 export ModuleCopy::Static := proc(new::Polygon, proto::Polygon, Ps, $)
  new:-vertices := Ps;
 end proc;

 export ModulePrint::static := proc(self::Polygon)
  return self:-vertices;
 end proc;
end module:

P1 := Polygon(Array([Point(3,4), Point(5,11), Point(12,8), Point(9,5), Point(5,6)])):
area(P1);


((((first) map) ((last) map)) cleave) :dezip
(((first) (rest)) cleave append) :rotate
((0 <) (-1 *) when) :abs

(
  =b =a a size :n 0 :i () =list
  (i n <) (
    a i get b i get ' prepend list append #list
    i succ @i
  ) while list
) :rezip

(rezip (-> *) map sum) :cross-sum

(
  ((dezip rotate) (dezip swap rotate)) cleave
  ((id) (cross-sum) (id) (cross-sum)) spread
  - abs 2 /
) :shoelace

((3 4) (5 11) (12 8) (9 5) (5 6)) shoelace print


shoelace = function(vertices)
    sum = 0
    points = vertices.len

    for i in range(0,points-2)
        sum = sum + vertices[i][0]*vertices[i+1][1]
    end for
    sum = sum + vertices[points-1][0]*vertices[0][1]

    for i in range(points-1,1)
        sum = sum - vertices[i][0]*vertices[i-1][1]
    end for
    sum = sum - vertices[0][0]*vertices[points-1][1]

    return abs(sum)/2
end function

verts = [[3,4],[5,11],[12,8],[9,5],[5,6]]

print "The polygon area is "  + shoelace(verts)


MODULE ShoelaceFormula;
FROM RealStr IMPORT RealToStr;
FROM FormatString IMPORT FormatString;
FROM Terminal IMPORT WriteString,WriteLn,ReadChar;

TYPE
    Point = RECORD
        x,y : INTEGER;
    END;

PROCEDURE PointToString(self : Point; VAR buf : ARRAY OF CHAR);
BEGIN
    FormatString("(%i, %i)", buf, self.x, self.y);
END PointToString;

PROCEDURE ShoelaceArea(v : ARRAY OF Point) : REAL;
VAR
    a : REAL;
    i,n : INTEGER;
BEGIN
    n := HIGH(v);
    a := 0.0;
    FOR i:=0 TO n-1 DO
        a := a + FLOAT(v[i].x * v[i+1].y - v[i+1].x * v[i].y);
    END;
    RETURN ABS(a + FLOAT(v[n].x * v[0].y - v[0].x * v[n].y)) / 2.0;
END ShoelaceArea;

VAR
    v : ARRAY[0..4] OF Point;
    buf : ARRAY[0..63] OF CHAR;
    area : REAL;
    i : INTEGER;
BEGIN
    v[0] := Point{3,4};
    v[1] := Point{5,11};
    v[2] := Point{12,8};
    v[3] := Point{9,5};
    v[4] := Point{5,6};
    area := ShoelaceArea(v);

    WriteString("Given a polygon with verticies ");
    FOR i:=0 TO HIGH(v) DO
        PointToString(v[i], buf);
        WriteString(buf);
        WriteString(" ");
    END;
    WriteLn;

    RealToStr(area, buf);
    WriteString("its area is ");
    WriteString(buf);
    WriteLn;

    ReadChar;
END ShoelaceFormula.


type
  Point = tuple
    x: float
    y: float

func shoelace(points: openArray[Point]): float =
  var leftSum, rightSum = 0.0
  for i in 0..<len(points):
    var j = (i + 1) mod len(points)
    leftSum  += points[i].x * points[j].y
    rightSum += points[j].x * points[i].y
  0.5 * abs(leftSum - rightSum)

var points = [(3.0, 4.0), (5.0, 11.0), (12.0, 8.0), (9.0, 5.0), (5.0, 6.0)]

echo shoelace(points)


with javascript_semantics
enum X, Y
function shoelace(sequence s)
    atom t = 0
    if length(s)>2 then
        s = append(deep_copy(s),s[1])
        for i=1 to length(s)-1 do
            t += s[i][X]*s[i+1][Y] - s[i+1][X]*s[i][Y]
        end for
    end if
    return abs(t)/2
end function

constant test = {{3,4},{5,11},{12,8},{9,5},{5,6}}
?shoelace(test)


#COMPILE EXE
#DIM ALL
#COMPILER PBCC 6

FUNCTION ShoelaceArea(x() AS DOUBLE, y() AS DOUBLE) AS DOUBLE
LOCAL i, j AS LONG
LOCAL Area AS DOUBLE

  j = UBOUND(x())
  FOR i = LBOUND(x()) TO UBOUND(x())
    Area += (y(j) + y(i)) * (x(j) - x(i))
    j = i
  NEXT i
  FUNCTION = ABS(Area) / 2
END FUNCTION

FUNCTION PBMAIN () AS LONG
  REDIM x(0 TO 4) AS DOUBLE, y(0 TO 4) AS DOUBLE
  ARRAY ASSIGN x() = 3, 5, 12, 9, 5
  ARRAY ASSIGN y() = 4, 11, 8, 5, 6
  CON.PRINT STR$(ShoelaceArea(x(), y()))
  CON.WAITKEY$
END FUNCTION


>>> def area_by_shoelace(x, y):
    "Assumes x,y points go around the polygon in one direction"
    return abs( sum(i * j for i, j in zip(x,             y[1:] + y[:1]))
               -sum(i * j for i, j in zip(x[1:] + x[:1], y            ))) / 2

>>> points = [(3,4), (5,11), (12,8), (9,5), (5,6)]
>>> x, y = zip(*points)
>>> area_by_shoelace(x, y)
30.0
>>>


#lang racket/base

(struct P (x y))

(define (area . Ps)
  (define (A P-a P-b)
    (+ (for/sum ((p_i Ps)
                 (p_i+1 (in-sequences (cdr Ps)
                                      (in-value (car Ps)))))
         (* (P-a p_i) (P-b p_i+1)))))
  (/ (abs (- (A P-x P-y) (A P-y P-x))) 2))

(module+ main
  (area (P 3 4) (P 5 11) (P 12 8) (P 9 5) (P 5 6)))


/*REXX program uses  a  Shoelace  formula to calculate the area of an  N─sided  polygon.*/
parse arg $;  if $=''  then $= "(3,4),(5,11),(12,8),(9,5),(5,6)"      /*Use the default?*/
A= 0;                  @= space($, 0)                   /*init A; elide blanks from pts.*/
         do #=1  until @=='';      parse var  @    '('   x.#   ","   y.#   ')'   ","   @
         end   /*#*/                                    /* [↨]  get X and Y coördinates.*/
z= #+1;                 y.0= y.#;  y.z= y.1             /*define low & high Y end points*/
         do j=1  for #;  jm= j-1;  jp= j+1;   A= A + x.j*(y.jm - y.jp) /*portion of area*/
         end   /*j*/                                    /*stick a fork in it, we're done*/
say 'polygon area of '      #      " points: "       $       '  is ───► '        abs(A/2)


# Project : Shoelace formula for polygonal area

p = [[3,4], [5,11], [12,8], [9,5], [5,6]]
see "The area of the polygon = " + shoelace(p)

func shoelace(p)
        sum = 0
        for i = 1 to len(p) -1
             sum = sum + p[i][1] * p[i +1][2]
             sum = sum - p[i +1][1] * p[i][2]
        next
        sum = sum + p[i][1] * p[1][2]
        sum = sum - p[1][1] * p[i][2]
        return fabs(sum) / 2


Point = Struct.new(:x,:y) do

  def shoelace(other)
    x * other.y - y * other.x
  end

end

class Polygon

  def initialize(*coords)
    @points = coords.map{|c| Point.new(*c) }
  end

  def area
    points = @points + [@points.first]
    points.each_cons(2).sum{|p1,p2| p1.shoelace(p2) }.abs.fdiv(2)
  end

end

puts Polygon.new([3,4], [5,11], [12,8], [9,5], [5,6]).area  # => 30.0


case class Point( x:Int,y:Int ) { override def toString = "(" + x + "," + y + ")" }

case class Polygon( pp:List[Point] ) {
  require( pp.size > 2, "A Polygon must consist of more than two points" )

  override def toString = "Polygon(" + pp.mkString(" ", ", ", " ") + ")"

  def area = {

    // Calculate using the Shoelace Formula
    val xx = pp.map( p => p.x )
    val yy = pp.map( p => p.y )
    val overlace = xx zip yy.drop(1)++yy.take(1)
    val underlace = yy zip xx.drop(1)++xx.take(1)

    (overlace.map( t => t._1 * t._2 ).sum - underlace.map( t => t._1 * t._2 ).sum).abs / 2.0
  }
}

// A little test...
{
val p = Polygon( List( Point(3,4), Point(5,11), Point(12,8), Point(9,5), Point(5,6) ) )

assert( p.area == 30.0 )

println( "Area of " + p + " = " + p.area )
}


import Foundation

struct Point {
  var x: Double
  var y: Double
}

extension Point: CustomStringConvertible {
  var description: String {
    return "Point(x: \(x), y: \(y))"
  }
}

struct Polygon {
  var points: [Point]

  var area: Double {
    let xx = points.map({ $0.x })
    let yy = points.map({ $0.y })
    let overlace = zip(xx, yy.dropFirst() + yy.prefix(1)).map({ $0.0 * $0.1 }).reduce(0, +)
    let underlace = zip(yy, xx.dropFirst() + xx.prefix(1)).map({ $0.0 * $0.1 }).reduce(0, +)

    return abs(overlace - underlace) / 2
  }

  init(points: [Point]) {
    self.points = points
  }

  init(points: [(Double, Double)]) {
    self.init(points: points.map({ Point(x: $0.0, y: $0.1) }))
  }
}

let poly = Polygon(points: [
  (3,4),
  (5,11),
  (12,8),
  (9,5),
  (5,6)
])

print("\(poly) area = \(poly.area)")


Option Base 1
Public Enum axes
    u = 1
    v
End Enum
Private Function shoelace(s As Collection) As Double
    Dim t As Double
    If s.Count > 2 Then
        s.Add s(1)
        For i = 1 To s.Count - 1
            t = t + s(i)(u) * s(i + 1)(v) - s(i + 1)(u) * s(i)(v)
        Next i
    End If
    shoelace = Abs(t) / 2
End Function

Public Sub polygonal_area()
    Dim task() As Variant
    task = [{3,4;5,11;12,8;9,5;5,6}]
    Dim tcol As New Collection
    For i = 1 To UBound(task)
        tcol.Add Array(task(i, u), task(i, v))
    Next i
    Debug.Print shoelace(tcol)
End Sub


' Shoelace formula for polygonal area - VBScript
    Dim points, x(),y()
    points = Array(3,4, 5,11, 12,8, 9,5, 5,6)
    n=(UBound(points)+1)\2
    Redim x(n+1),y(n+1)
    j=0
    For i = 1 To n
        x(i)=points(j)
        y(i)=points(j+1)
        j=j+2
    Next 'i
    x(i)=points(0)
    y(i)=points(1)
    For i = 1 To n
        area = area + x(i)*y(i+1) - x(i+1)*y(i)
    Next 'i
    area = Abs(area)/2
    msgbox area,,"Shoelace formula"


Option Explicit

Public Function ShoelaceArea(x() As Double, y() As Double) As Double
Dim i As Long, j As Long
Dim Area As Double

  j = UBound(x())
  For i = LBound(x()) To UBound(x())
    Area = Area + (y(j) + y(i)) * (x(j) - x(i))
    j = i
  Next i
  ShoelaceArea = Abs(Area) / 2
End Function

Sub Main()
Dim v As Variant
Dim n As Long, i As Long, j As Long
  v = Array(3, 4, 5, 11, 12, 8, 9, 5, 5, 6)
  n = (UBound(v) - LBound(v) + 1) \ 2 - 1
  ReDim x(0 To n) As Double, y(0 To n) As Double
  j = 0
  For i = 0 To n
    x(i) = v(j)
    y(i) = v(j + 1)
    j = j + 2
  Next i
  Debug.Print ShoelaceArea(x(), y())
End Sub


Option Strict On

Imports Point = System.Tuple(Of Double, Double)

Module Module1

    Function ShoelaceArea(v As List(Of Point)) As Double
        Dim n = v.Count
        Dim a = 0.0
        For i = 0 To n - 2
            a += v(i).Item1 * v(i + 1).Item2 - v(i + 1).Item1 * v(i).Item2
        Next
        Return Math.Abs(a + v(n - 1).Item1 * v(0).Item2 - v(0).Item1 * v(n - 1).Item2) / 2.0
    End Function

    Sub Main()
        Dim v As New List(Of Point) From {
            New Point(3, 4),
            New Point(5, 11),
            New Point(12, 8),
            New Point(9, 5),
            New Point(5, 6)
        }
        Dim area = ShoelaceArea(v)
        Console.WriteLine("Given a polygon with vertices [{0}],", String.Join(", ", v))
        Console.WriteLine("its area is {0}.", area)
    End Sub

End Module


var shoelace = Fn.new { |pts|
    var area = 0
    for (i in 0...pts.count-1) {
        area = area + pts[i][0]*pts[i+1][1] - pts[i+1][0]*pts[i][1]
    }
    return (area + pts[-1][0]*pts[0][1] - pts[0][0]*pts[-1][1]).abs / 2
}

var pts = [ [3, 4], [5, 11], [12, 8], [9, 5], [5, 6] ]
System.print("The polygon with vertices at %(pts) has an area of %(shoelace.call(pts)).")


fcn areaByShoelace(points){	// ( (x,y),(x,y)...)
   xs,ys:=Utils.Helpers.listUnzip(points); // (x,x,...), (y,y,,,)
   ( xs.zipWith('*,ys[1,*]).sum(0) + xs[-1]*ys[0] -
     xs[1,*].zipWith('*,ys).sum(0) - xs[0]*ys[-1] )
   .abs().toFloat()/2;
}


...>echo L(i) 0..10 {print("Hello World"[0..i])} > oneliner.11l && 11l oneliner.11l && oneliner.exe
H
He
Hel
Hell
Hello
Hello
Hello W
Hello Wo
Hello Wor
Hello Worl
Hello World


echo 'with Ada.text_IO; use Ada.text_IO; procedure X is begin Put("Hello!"); end X;' > x.adb; gnatmake x; ./x; rm x.adb x.ali x.o x


$ src/aime -c 'o_text("Hello, World!\n");'


$ echo 'print "Hello "; var=99; ++var + 20 + 3' | bc


$ echo 'main() {printf("Hello\n");}' | gcc -w -x c -; ./a.out


> Add-Type -TypeDefinition "public class HelloWorld { public static void SayHi() { System.Console.WriteLine(""Hi!""); } }"
> [HelloWorld]::SayHi()
Hi!


$ clj-env-dir -e "(defn add2 [x] (inc (inc x))) (add2 40)"
#'user/add2
42


echo 'message(STATUS "Goodbye, World!")' | cmake -P /dev/stdin


echo 'display "hello".' | cobc -xFj -frelax -


sbcl --noinform --eval '(progn (princ "Hello") (terpri) (quit))'


L(i) 16
   L(j) (32 + i .. 127).step(16)
      String k
      I j == 32
         k = ‘Spc’
      E I j == 127
         k = ‘Del’
      E
         k = Char(code' j)
      print(‘#3 : #<3’.format(j, k), end' ‘’)
   print()


echo program Prog;begin writeln('Hi');end. >> "./a.dpt" & dcc32 -Q -CC -W- "./a.dpt" & a.exe


$ elixir -e "IO.puts 'Hello, World!'"
Hello, World!


emacs -batch -eval '(princ "Hello World!\n")'


$ erl -noshell -eval 'io:format("hello~n").' -s erlang halt
hello


==========================================================================
; task    : show ascii table
; language: 6502 Assembly
; for:    : rosettacode.org
; run     : on a Commodore 64 with command
;           sys 49152
;
; same logic of "Commodore BASIC"
;
; assembler win2c64 by Aart Bik
; http://www.aartbik.com/
;
; 2020-05-01 alvalongo
;==========================================================================
; constants
cr         = 13    ; carriage-return
white      = 5     ; color white
; ----------------------------------------------
; memory on zero page
linnum     = $14
; ----------------------------------------------
; kernel routines
linstr    = $bdcd   ; C64 ROM       : convert a 16-bit value to string and print on current device (default screen)
chrout    = $ffd2   ; C64 ROM kernel: output a character to current device, default screen
			        ;                 use $fded for Apple 2
;
; ----------------------------------------------
;
        .org   $c000   ; start at free RAM, on Commodore 64
; ----------------------------------------------
l100    lda #147       ; clear screen
        jsr chrout
        ;
l110    lda #14         ;character set 2, upper/lower case mode
        jsr chrout
        ;
        lda #white      ; color for characters
        jsr chrout
        ;
l120    lda #<msg1
        ldx #>msg1
        jsr prtmsg
        ;
l130    lda #<msg2
        ldx #>msg2
        jsr prtmsg
        ;
l140    lda #cr
        jsr chrout
        ;
l150    lda #0
        sta row
        ;
l160    lda #0
        sta column
        ;
l170    clc
        lda row
        adc #32
        sta ascii
        lda column
        asl     ; times 2,  2
        asl     ; times 2,  4
        asl     ; times 2,  8
        asl     ; times 2, 16
        adc ascii
        sta ascii
        ;
l180    cmp #100
        bcs l185     ; equal or greater than
        lda #" "     ; a space before values less than 100
        jsr chrout
        ;
l185    ldx ascii
        lda #0
        jsr linstr       ; convert to string and print on screen
        lda #":"
        jsr chrout
        lda ascii
        jsr chrout
        lda #" "
        jsr chrout
        ;
l190    inc column  ; next column
        lda column
        cmp #5
        bcc l170
        beq l170
        ;
l200    lda #cr
        jsr chrout
        ;
l210    inc row    ; next row
        lda row
        cmp #15
        bcc l160
        beq l160
        ;
l220    rts      ; return to operating system
; ----------------------------------------------
; print message
;
prtmsg  sta linnum
        stx linnum+1
        ldy #0
l310    lda (linnum),y
        beq l320
        jsr chrout
        iny
        bne l310
l320    lda #cr
        jsr chrout
        rts
; ----------------------------------------------
msg1    .byte "COMMODORE 64 - BASIC V2",0
msg2    .byte "CHARACTER SET 2 UPPER/LOWER CASE MODE",0
row     .byte 0
column  .byte 0
ascii   .byte 0


> echo printfn "Hello from F#" | fsi --quiet
Hello from F#


$ factor -run=none -e="USE: io \"hi\" print"


$ gawk 'BEGIN{print"write(6,\"(2(g12.3,x))\")(i/10.0,besj1(i/10.0), i=0,1000)\nend";exit(0)}'|gfortran -ffree-form -x f95 - | gnuplot -p -e 'plot "<./a.out" t "Bessel function of 1st kind" w l'


	org	100h
	mvi	a,32		; Start with space
	mvi	d,16		; 16 lines
dochar:	mov	c,a		; Print number
	call	putnum
	mov	a,c
	lxi	h,spc		; Is it space?
	cpi	32
	jz	print
	lxi	h,del
	cpi	127		; Is it del?
	jz	print
	lxi	h,chr		; Character
	mov	m,a
print:	call	puts
	adi	16		; Next column
	jp	dochar		; Done with this line?
	lxi	h,nl
	call	puts
	sui	95		; Next line
	dcr	d
	jnz	dochar
	ret
	;;;	Print number in A. C, D preserved.
putnum:	lxi	h,num		; Set number string to spaces
	push	h
	mvi	b,' '
	mov	m,b
	inx	h
	mov	m,b
	inx	h
	mov	m,b
dgts:	mvi 	b,-1
divmod:	sui	10		; B = A/10, A = (A mod 10)-10
	inr	b
	jnc	divmod
	adi	58		; Make digit
	mov	m,a		; Store digit
	dcx	h
	mov	a,b		; Next digit
	ana	a
	jnz	dgts
	pop	h		; Print number
	;;;	Print zero-terminated (...ish) string
puts:	mov	e,m
	call	putch
	inx	h
	dcr	e
	jp	puts
	ret
	;;;	Output character in E using CP/M call,
	;;;	preserving registers
putch:	push	psw
	push	b
	push	d
	push	h
	mvi	c,2
	call	5
	pop	h
	pop	d
	pop	b
	pop	psw
	ret
nl:	db	13,10,0		; Newline
num:	db	'   : ',0	; Placeholder for number string
spc:	db	'Spc  ',0	; Space
del:	db 	'Del  ',0	; Del
chr: 	db	'*    ',0	; Placeholder for character


	cpu	8086
	bits	16
putch:	equ	2h
section	.text
	org	100h
	mov	cx,16		; 16 lines
	mov	bh,32		; Start at 32
dochar:	mov	al,bh		; Print number
	call	putnum
	cmp	bh,32 		; Space?
	je	.spc
	cmp	bh,127 		; Del?
	je	.del
	mov	[chr],bh	; Otherwise, print character
	mov	di,chr
	jmp 	.out
.spc:	mov	di,spc
	jmp 	.out
.del:	mov	di,del
.out:	call	putstr
	add	bh,16		; Next column
	cmp	bh,128		; Done with this line?
	jb	dochar
	mov	di,nl		; Print newline
	call	putstr
	sub	bh,95		; Do next line
	loop	dochar
	ret
	;;;	Print number in AL as ASCII, right-aligned in 3 characters
putnum:	mov	dx,2020h	; Put spaces in number
	mov	di,num		; Two spaces
	mov	[di],dx
	inc	di
	inc	di
	mov	[di],dh		; Third space
	mov	bl,10		; Divisor
.div:	xor	ah,ah		; Write digits
	div	bl
	add	ah,'0'
	mov	[di],ah
	dec	di
	test	al,al
	jnz	.div
	mov	di,num		; Print number
putstr:	mov	ah,putch	; Use zero-terminated strings
.loop:	mov	dl,[di]
	test	dl,dl
	jz	.done
	int	21h
	inc	di
	jmp	.loop
.done:	ret
section	.data
num:	db	'   : ',0	; Placeholder for number string
nl:	db	13,10,0		; Newline
spc:	db	'Spc  ',0	; Space
del:	db	'Del  ',0	; Del
chr:	db	'*    ',0	; Placeholder for character


echo "begin writeLn('Hi'); end." | ifpc /dev/stdin


' FB 1.05.0 Win64

Shell "echo For i As Integer = 1 To 10 : Print i : Next > zzz.bas && fbc zzz.bas && zzz"
Sleep


window 1,,(0,0,160,120):Str255 a:open "Unix",1,"cal 10 2018":do:line input #1,a:print a:until eof(1):close 1:HandleEvents


Public Sub Main()

Shell "echo Hello World"

End


$ gema -p '\B=Hello\[email protected]'
Hello


echo 'package main;func main(){println("hlowrld")}'>/tmp/h.go;go run /tmp/h.go


PROC Main()
  BYTE
    count=[96],rows=[16],
    first=[32],last=[127],
    i,j

  Put(125) ;clear screen

  FOR i=0 TO rows-1
  DO
    Position(2,3+i)

    FOR j=first+i TO last STEP rows
    DO
      IF j>=96 AND j<=99 THEN
        Put(' )
      FI
      PrintB(j)
      Put(' )

      IF j=32 THEN
        Print("SP ")
      ELSEIF j=125 THEN
        Print("CL")
      ELSEIF j=126 THEN
        Print("DL")
      ELSEIF j=127 THEN
        Print("TB")
      ELSE
        PrintF("%C  ",j)
      FI
    OD
    PutE()
  OD
RETURN


with Ada.Text_IO;         use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Ascii_Table is
   N : Integer;
begin
   for R in 0 .. 15 loop
      for C in 0 .. 5 loop
         N := 32 + 16 * C + R;
         Put (N, 3);
         Put (" : ");
         case N is
            when 32 =>
               Put ("Spc  ");
            when 127 =>
               Put ("Del  ");
            when others =>
               Put (Character'Val (N) & "    ");
         end case;
      end loop;
      New_Line;
   end loop;
end Ascii_Table;


echo "procedure main();write(\"hello\");end" | icont - -x


$ jconsole -js "exit echo 'Hello'"
Hello


$ echo 'public class X{public static void main(String[]args){' \
>     'System.out.println("Hello Java!");}}' >X.java
$ javac X.java && java X


BEGIN
    # generate an ascii table for characters 32 - 127 #
    INT    char count := 1;
    FOR c FROM 32 TO 127 DO
        print( ( whole( c, -4 )
               , ": "
               , IF   c =  32 THEN "SPC"
                 ELIF c = 127 THEN "DEL"
                 ELSE " " + REPR c + " "
                 FI
               )
             );
        IF char count = 0 THEN print( ( newline ) ) FI;
        ( char count PLUSAB 1 ) MODAB 6
    OD
END


begin
    % generate an ascii table for chars 32 - 127            %
    integer cPos;
    cPos := 0;
    for i := 32 until 127 do begin
        if cPos = 0 then write();
        cPos := ( cPos + 1 ) rem 6;
        writeon( i_w := 3, s_w := 0, i, ": " );
        if      i =  32 then writeon( "Spc ")
        else if i = 127 then writeon( "Del " )
        else                 writeon( code( i ), "   " )
    end for_i
end.


$ julia -e 'for x in ARGS; println(x); end' foo bar
foo
bar


echo 'fun main(args: Array<String>) = println("Hello Kotlin!")' >X.kt;kotlinc X.kt -include-runtime -d X.jar && java -jar X.jar


echo " 'The date and time is: ' + date " | lasso9 --


echo print "hello">oneLiner.bas & liberty -r oneLiner.bas echo print "hello">oneLiner.bas & liberty -r oneLiner.bas


-- asciiTable :: () -> String
on asciiTable()
    script row
        on |λ|(x)
            concat(map(justifyLeft(12, space), x))
        end |λ|
    end script

    unlines(map(row, ¬
        transpose(chunksOf(16, map(my asciiEntry, ¬
            enumFromTo(32, 127))))))
end asciiTable

-------------------------- TEST ---------------------------
on run

    asciiTable()

end run

------------------------- DISPLAY -------------------------

-- asciiEntry :: Int -> String
on asciiEntry(n)
    set k to asciiName(n)
    if "" ≠ k then
        justifyRight(4, space, n as string) & " : " & k
    else
        k
    end if
end asciiEntry

-- asciiName :: Int -> String
on asciiName(n)
    if 32 > n or 127 < n then
        ""
    else if 32 = n then
        "Spc"
    else if 127 = n then
        "Del"
    else
        chr(n)
    end if
end asciiName

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

-- chr :: Int -> Char
on chr(n)
    character id n
end chr

-- chunksOf :: Int -> [a] -> [[a]]
on chunksOf(k, xs)
    script
        on go(ys)
            set ab to splitAt(k, ys)
            set a to |1| of ab
            if {} ≠ a then
                {a} & go(|2| of ab)
            else
                a
            end if
        end go
    end script
    result's go(xs)
end chunksOf

-- concat :: [[a]] -> [a]
-- concat :: [String] -> String
on concat(xs)
    set lng to length of xs
    if 0 < lng and string is class of (item 1 of xs) then
        set acc to ""
    else
        set acc to {}
    end if
    repeat with i from 1 to lng
        set acc to acc & item i of xs
    end repeat
    acc
end concat

-- concatMap :: (a -> [b]) -> [a] -> [b]
on concatMap(f, xs)
    set lng to length of xs
    if 0 < lng and class of xs is string then
        set acc to ""
    else
        set acc to {}
    end if
    tell mReturn(f)
        repeat with i from 1 to lng
            set acc to acc & |λ|(item i of xs, i, xs)
        end repeat
    end tell
    return acc
end concatMap

-- enumFromTo :: Int -> Int -> [Int]
on enumFromTo(m, n)
    if m ≤ n then
        set lst to {}
        repeat with i from m to n
            set end of lst to i
        end repeat
        return lst
    else
        return {}
    end if
end enumFromTo

-- 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

-- justifyLeft :: Int -> Char -> String -> String
on justifyLeft(n, cFiller)
    script
        on |λ|(strText)
            if n > length of strText then
                text 1 thru n of (strText & replicate(n, cFiller))
            else
                strText
            end if
        end |λ|
    end script
end justifyLeft

-- justifyRight :: Int -> Char -> String -> String
on justifyRight(n, cFiller, strText)
    if n > length of strText then
        text -n thru -1 of ((replicate(n, cFiller) as text) & strText)
    else
        strText
    end if
end justifyRight

-- length :: [a] -> Int
on |length|(xs)
    length of xs
end |length|

-- 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 :: First-class m => (a -> b) -> m (a -> b)
on mReturn(f)
    if class of f is script then
        f
    else
        script
            property |λ| : f
        end script
    end if
end mReturn

-- Egyptian multiplication - progressively doubling a list, appending
-- stages of doubling to an accumulator where needed for binary
-- assembly of a target length
-- replicate :: Int -> a -> [a]
on replicate(n, a)
    set out to {}
    if n < 1 then return out
    set dbl to {a}

    repeat while (n > 1)
        if (n mod 2) > 0 then set out to out & dbl
        set n to (n div 2)
        set dbl to (dbl & dbl)
    end repeat
    return out & dbl
end replicate

-- splitAt :: Int -> [a] -> ([a],[a])
on splitAt(n, xs)
    if n > 0 and n < length of xs then
        if class of xs is text then
            Tuple(items 1 thru n of xs as text, items (n + 1) thru -1 of xs as text)
        else
            Tuple(items 1 thru n of xs, items (n + 1) thru -1 of xs)
        end if
    else
        if n < 1 then
            Tuple({}, xs)
        else
            Tuple(xs, {})
        end if
    end if
end splitAt

-- Tuple (,) :: a -> b -> (a, b)
on Tuple(a, b)
    {type:"Tuple", |1|:a, |2|:b, length:2}
end Tuple

-- Simplified version - assuming rows of unvarying length.
-- transpose :: [[a]] -> [[a]]
on transpose(rows)
    script cols
        on |λ|(_, iCol)
            script cell
                on |λ|(row)
                    item iCol of row
                end |λ|
            end script
            concatMap(cell, rows)
        end |λ|
    end script
    map(cols, item 1 of rows)
end transpose

-- unlines :: [String] -> String
on unlines(xs)
    set {dlm, my text item delimiters} to ¬
        {my text item delimiters, linefeed}
    set str to xs as text
    set my text item delimiters to dlm
    str
end unlines


echo Print[2+2] > file & math.exe -script file


let x 15 ask turtles [ set xcor x set x x + 1 ]


$ TNRX=`mktemp T_XXXXXXXXXXXX` && test ! -e $TNRX.* && (echo 'say "Goodbye, World!"' >$TNRX; nrc -exec $TNRX; rm $TNRX $TNRX.*; unset TNRX)


$ echo 'for i in 0..10: echo "Hello World"[0..i]' >/tmp/oneliner.nim; nim r oneliner
H
He
Hel
Hell
Hello
Hello
Hello W
Hello Wo
Hello Wor
Hello Worl
Hello World


 0  GOTO 10: ONERR AI READ LY RND
 10  LET X = 256 *  PEEK (104)
 11  LET X = X +  PEEK (103) + 7
 20  CALL  - 1184:B$ =  CHR$ (8)
 21  NORMAL : PRINT :E = 61588
 22  PRINT  TAB( 29)"APPLESOFT";
 23  PRINT " II"B$:M =  - 1
 24  PRINT  TAB( 22)"BASED ON ";
 25  FOR I = E + 9 TO E STEP M
 26  POKE 65, PEEK (I): CALL X
 27  NEXT : PRINT B$:S$ = "  "
 28  PRINT  TAB( 28)"6502 ";
 29  PRINT "BASIC V2" CHR$ (8)
 30  PRINT "CHARACTER SET"
 40  FOR R = 0 TO 15: PRINT
 50  FOR C = 2 TO 7:A = C * 16
 60  LET N$ = S$ +  STR$ (A + R)
 70  LET N$ =  RIGHT$ (N$,4)
 80  PRINT N$":" CHR$ (A + R);
 90  NEXT C,R: PRINT


.equ CursorX,0x02000000
.equ CursorY,0x02000001
ProgramStart:
	mov sp,#0x03000000			;Init Stack Pointer

	mov r4,#0x04000000  		        ;DISPCNT -LCD Control
	mov r2,#0x403    			;4= Layer 2 on / 3= ScreenMode 3
	str	r2,[r4]         	        ;now the screen is visible
	bl ResetTextCursors			;set text cursors to top left of screen

	mov r2,#32
	mov r3,#32+20				;screen height is 20 chars
	mov r5,#0				;column spacer
	mov r6,#5

	;R0 = Character to print (working copy)
	;R2 = real copy
	;R3 = compare factor
loop_printAscii:
	mov r0,r2
	bl ShowHex

	mov r0,#32
	bl PrintChar

	mov r0,r2
	bl PrintChar

	bl CustomNewLine
	add r2,r2,#1

	cmp r2,#128
	beq forever		;exit early

	cmp r2,r3
	bne loop_printAscii

	add r3,r3,#20	;next section

	;inc to next column
	add r5,r5,#5
	mov r0,r5
	mov r1,#0
	bl SetTextCursors
	subs r6,r6,#1
	bne loop_printAscii

forever:
	b forever

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;		INPUT/OUTPUT SUBROUTINES   		- 		CREATED BY KEITH OF CHIBIAKUMAS.COM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

PrintString:					;Print 255 terminated string
	STMFD sp!,{r0-r12, lr}
PrintStringAgain:
		ldrB r0,[r1],#1
		cmp r0,#255
		beq PrintStringDone		;Repeat until 255
		bl printchar 			;Print Char
		b PrintStringAgain
PrintStringDone:
	LDMFD sp!,{r0-r12, pc}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintChar:
	STMFD sp!,{r0-r12, lr}
	mov r4,#0
		mov r5,#0

		mov r3,#CursorX
		ldrB r4,[r3]			;X pos
		mov r3,#CursorY
		ldrB r5,[r3]			;Y pos

		mov r3,#0x06000000 		;VRAM base

		mov r6,#8*2				;Xpos, 2 bytes per pixel, 8 bytes per char
		mul r2,r4,r6
		add r3,r3,r2

		mov r4,#240*8*2			;Ypos, 240 pixels per line,
		mul r2,r5,r4			;2 bytes per pixel, 8 lines per char
		add r3,r3,r2

		adr r4,BitmapFont 		;Font source

		sub r0,r0,#32			;First Char is 32 (space)
		add r4,r4,r0,asl #3		;8 bytes per char

		mov r1,#8				;8 lines
DrawLine:
		mov r7,#8 				;8 pixels per line
		ldrb r8,[r4],#1			;Load Letter
		mov r9,#0b100000000		;Mask

		mov r2, #0b1111111101000000; Color: ABBBBBGGGGGRRRRR   A=Alpha
DrawPixel:
		tst r8,r9				;Is bit 1?
		strneh r2,[r3]			;Yes? then fill pixel (HalfWord)
		add r3,r3,#2
		mov r9,r9,ror #1		;Bitshift Mask
		subs r7,r7,#1
		bne DrawPixel			;Next Hpixel

		add r3,r3,#480-16	   ;Move Down a line (240 pixels *2 bytes)
		subs r1,r1,#1								;-1 char (16 px)
		bne DrawLine			;Next Vline

LineDone:
		mov r3,#CursorX
		ldrB r0,[r3]
		add r0,r0,#1			;Move across screen
		strB r0,[r3]
		mov r10,#30
		cmp r0,r10
		bleq NewLine
	LDMFD sp!,{r0-r12, pc}

NewLine:
	STMFD sp!,{r0-r12, lr}
		mov r3,#CursorX
		mov r0,#0
		strB r0,[r3]
		mov r4,#CursorY
		ldrB r0,[r4]
		add r0,r0,#1
		strB r0,[r4]
	LDMFD sp!,{r0-r12, pc}

CustomNewLine:
	STMFD sp!,{r0-r12, lr}
		mov r3,#CursorX
		mov r0,r5
		strB r0,[r3]
		mov r4,#CursorY
		ldrB r0,[r4]
		add r0,r0,#1
		strB r0,[r4]
	LDMFD sp!,{r0-r12, pc}

ResetTextCursors:
	STMFD sp!,{r4-r6,lr}
		mov r4,#0
		mov r5,#CursorX
		mov r6,#CursorY
		strB r4,[r5]
		strB r4,[r6]
	LDMFD sp!,{r4-r6,lr}
	bx lr

SetTextCursors:
	;input: R0 = new X
	;	R1 = new Y
	STMFD sp!,{r5-r6}
		mov r5,#CursorX
		mov r6,#CursorY
		strB r0,[r5]
		strB r1,[r6]
	LDMFD sp!,{r5-r6}
	bx lr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

ShowHex:
	STMFD sp!,{r0-r12, lr}
		mov r2,r0,ror #4
		bl ShowHexChar
		mov r2,r0
		bl ShowHexChar
	LDMFD sp!,{r0-r12, pc}

ShowHexChar:
	STMFD sp!,{r0-r12, lr}
		;mov r3,
		and r0,r2,#0x0F ; r3
		cmp r0,#10
		addge r0,r0,#7			;if 10 or greater convert to alphabet letters a-f
		add r0,r0,#48
		bl PrintChar
	LDMFD sp!,{r0-r12, pc}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

BitmapFont:
;each byte represents a row of 8 pixels. This is a 1BPP font that is converted to the GBA's 16bpp screen format at runtime
        .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00     ; 20
        .byte 0x10,0x18,0x18,0x18,0x18,0x00,0x18,0x00     ; 21
        .byte 0x28,0x6C,0x28,0x00,0x00,0x00,0x00,0x00     ; 22
        .byte 0x00,0x28,0x7C,0x28,0x7C,0x28,0x00,0x00     ; 23
        .byte 0x18,0x3E,0x48,0x3C,0x12,0x7C,0x18,0x00     ; 24
        .byte 0x02,0xC4,0xC8,0x10,0x20,0x46,0x86,0x00     ; 25
        .byte 0x10,0x28,0x28,0x72,0x94,0x8C,0x72,0x00     ; 26
        .byte 0x0C,0x1C,0x30,0x00,0x00,0x00,0x00,0x00     ; 27
        .byte 0x18,0x18,0x30,0x30,0x30,0x18,0x18,0x00     ; 28
        .byte 0x18,0x18,0x0C,0x0C,0x0C,0x18,0x18,0x00     ; 29
        .byte 0x08,0x49,0x2A,0x1C,0x14,0x22,0x41,0x00     ; 2A
        .byte 0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00     ; 2B
        .byte 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30     ; 2C
        .byte 0x00,0x00,0x00,0x7E,0x7E,0x00,0x00,0x00     ; 2D
        .byte 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00     ; 2E
        .byte 0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00     ; 2F
        .byte 0x7C,0xC6,0xD6,0xD6,0xD6,0xC6,0x7C,0x00     ; 30
        .byte 0x10,0x18,0x18,0x18,0x18,0x18,0x08,0x00     ; 31
        .byte 0x3C,0x7E,0x06,0x3C,0x60,0x7E,0x3C,0x00     ; 32
        .byte 0x3C,0x7E,0x06,0x1C,0x06,0x7E,0x3C,0x00     ; 33
        .byte 0x18,0x3C,0x64,0xCC,0x7C,0x0C,0x08,0x00     ; 34
        .byte 0x3C,0x7E,0x60,0x7C,0x06,0x7E,0x3E,0x00     ; 35
        .byte 0x3C,0x7E,0x60,0x7C,0x66,0x66,0x3C,0x00     ; 36
        .byte 0x3C,0x7E,0x06,0x0C,0x18,0x18,0x10,0x00     ; 37
        .byte 0x3C,0x66,0x66,0x3C,0x66,0x66,0x3C,0x00     ; 38
        .byte 0x3C,0x66,0x66,0x3E,0x06,0x7E,0x3C,0x00     ; 39
        .byte 0x00,0x00,0x18,0x18,0x00,0x18,0x18,0x00     ; 3A
        .byte 0x00,0x00,0x18,0x18,0x00,0x18,0x18,0x30     ; 3B
        .byte 0x0C,0x1C,0x38,0x60,0x38,0x1C,0x0C,0x00     ; 3C
        .byte 0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00     ; 3D
        .byte 0x60,0x70,0x38,0x0C,0x38,0x70,0x60,0x00     ; 3E
        .byte 0x3C,0x76,0x06,0x1C,0x00,0x18,0x18,0x00     ; 3F
        .byte 0x7C,0xCE,0xA6,0xB6,0xC6,0xF0,0x7C,0x00     ; 40 @
        .byte 0x18,0x3C,0x66,0x66,0x7E,0x66,0x24,0x00     ; 41 A
        .byte 0x3C,0x66,0x66,0x7C,0x66,0x66,0x3C,0x00     ; 42 B
        .byte 0x38,0x7C,0xC0,0xC0,0xC0,0x7C,0x38,0x00     ; 43 C
        .byte 0x3C,0x64,0x66,0x66,0x66,0x64,0x38,0x00     ; 44 D
        .byte 0x3C,0x7E,0x60,0x78,0x60,0x7E,0x3C,0x00     ; 45 E
        .byte 0x38,0x7C,0x60,0x78,0x60,0x60,0x20,0x00     ; 46 F
        .byte 0x3C,0x66,0xC0,0xC0,0xCC,0x66,0x3C,0x00     ; 47 G
        .byte 0x24,0x66,0x66,0x7E,0x66,0x66,0x24,0x00     ; 48 H
        .byte 0x10,0x18,0x18,0x18,0x18,0x18,0x08,0x00     ; 49 I
        .byte 0x08,0x0C,0x0C,0x0C,0x4C,0xFC,0x78,0x00     ; 4A J
        .byte 0x24,0x66,0x6C,0x78,0x6C,0x66,0x24,0x00     ; 4B K
        .byte 0x20,0x60,0x60,0x60,0x60,0x7E,0x3E,0x00     ; 4C L
        .byte 0x44,0xEE,0xFE,0xD6,0xD6,0xD6,0x44,0x00     ; 4D M
        .byte 0x44,0xE6,0xF6,0xDE,0xCE,0xC6,0x44,0x00     ; 4E N
        .byte 0x38,0x6C,0xC6,0xC6,0xC6,0x6C,0x38,0x00     ; 4F O
        .byte 0x38,0x6C,0x64,0x7C,0x60,0x60,0x20,0x00     ; 50 P
        .byte 0x38,0x6C,0xC6,0xC6,0xCA,0x74,0x3A,0x00     ; 51 Q
        .byte 0x3C,0x66,0x66,0x7C,0x6C,0x66,0x26,0x00     ; 52 R
        .byte 0x3C,0x7E,0x60,0x3C,0x06,0x7E,0x3C,0x00     ; 53 S
        .byte 0x3C,0x7E,0x18,0x18,0x18,0x18,0x08,0x00     ; 54 T
        .byte 0x24,0x66,0x66,0x66,0x66,0x66,0x3C,0x00     ; 55 U
        .byte 0x24,0x66,0x66,0x66,0x66,0x3C,0x18,0x00     ; 56 V
        .byte 0x44,0xC6,0xD6,0xD6,0xFE,0xEE,0x44,0x00     ; 57 W
        .byte 0xC6,0x6C,0x38,0x38,0x6C,0xC6,0x44,0x00     ; 58 X
        .byte 0x24,0x66,0x66,0x3C,0x18,0x18,0x08,0x00     ; 59 Y
        .byte 0x7C,0xFC,0x0C,0x18,0x30,0x7E,0x7C,0x00     ; 5A Z
        .byte 0x1C,0x30,0x30,0x30,0x30,0x30,0x1C,0x00     ; 5B [
        .byte 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x00     ; 5C Backslash
        .byte 0x38,0x0C,0x0C,0x0C,0x0C,0x0C,0x38,0x00     ; 5D ]
        .byte 0x10,0x28,0x44,0x00,0x00,0x00,0x00,0x00     ; 5E ^
        .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C     ; 5F _
        .byte 0x10,0x08,0x00,0x00,0x00,0x00,0x00,0x00     ; 60 `
        .byte 0x00,0x00,0x38,0x0C,0x7C,0xCC,0x78,0x00     ; 61
        .byte 0x20,0x60,0x7C,0x66,0x66,0x66,0x3C,0x00     ; 62
        .byte 0x00,0x00,0x3C,0x66,0x60,0x66,0x3C,0x00     ; 63
        .byte 0x08,0x0C,0x7C,0xCC,0xCC,0xCC,0x78,0x00     ; 64
        .byte 0x00,0x00,0x3C,0x66,0x7E,0x60,0x3C,0x00     ; 65
        .byte 0x1C,0x36,0x30,0x38,0x30,0x30,0x10,0x00     ; 66
        .byte 0x00,0x00,0x3C,0x66,0x66,0x3E,0x06,0x3C     ; 67
        .byte 0x20,0x60,0x6C,0x76,0x66,0x66,0x24,0x00     ; 68
        .byte 0x18,0x00,0x18,0x18,0x18,0x18,0x08,0x00     ; 69
        .byte 0x06,0x00,0x04,0x06,0x06,0x26,0x66,0x3C     ; 6A
        .byte 0x20,0x60,0x66,0x6C,0x78,0x6C,0x26,0x00     ; 6B
        .byte 0x10,0x18,0x18,0x18,0x18,0x18,0x08,0x00     ; 6C
        .byte 0x00,0x00,0x6C,0xFE,0xD6,0xD6,0xC6,0x00     ; 6D
        .byte 0x00,0x00,0x3C,0x66,0x66,0x66,0x24,0x00     ; 6E
        .byte 0x00,0x00,0x3C,0x66,0x66,0x66,0x3C,0x00     ; 6F
        .byte 0x00,0x00,0x3C,0x66,0x66,0x7C,0x60,0x20     ; 70
        .byte 0x00,0x00,0x78,0xCC,0xCC,0x7C,0x0C,0x08     ; 71
        .byte 0x00,0x00,0x38,0x7C,0x60,0x60,0x20,0x00     ; 72
        .byte 0x00,0x00,0x3C,0x60,0x3C,0x06,0x7C,0x00     ; 73
        .byte 0x10,0x30,0x3C,0x30,0x30,0x3E,0x1C,0x00     ; 74
        .byte 0x00,0x00,0x24,0x66,0x66,0x66,0x3C,0x00     ; 75
        .byte 0x00,0x00,0x24,0x66,0x66,0x3C,0x18,0x00     ; 76
        .byte 0x00,0x00,0x44,0xD6,0xD6,0xFE,0x6C,0x00     ; 77
        .byte 0x00,0x00,0xC6,0x6C,0x38,0x6C,0xC6,0x00     ; 78
        .byte 0x00,0x00,0x24,0x66,0x66,0x3E,0x06,0x7C     ; 79
        .byte 0x00,0x00,0x7E,0x0C,0x18,0x30,0x7E,0x00     ; 7A
        .byte 0x10,0x20,0x20,0x40,0x40,0x20,0x20,0x10     ; 7B {
        .byte 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10     ; 7C |
        .byte 0x08,0x04,0x04,0x02,0x02,0x04,0x04,0x08     ; 7D }
        .byte 0x00,0x00,0x00,0x20,0x52,0x0C,0x00,0x00     ; 7E ~
        .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00     ; 7F
	.byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF	  ; 80


./obc -run '"Hello"->PrintLine();' -dest hello.obe ; ./obr hello.obe


$ ocaml <(echo 'print_endline "Hello"')
Hello


$ octave --eval 'printf("Hello World, it is %s!\n",datestr(now));'
Hello World, it is 28-Aug-2013 17:53:47!


oforth --P"1000 seq map(#sqrt) sum print"


echo >tmp.oz "{System.show hello}"; ozc -l System -e tmp.oz
hello


loop 32..127 'num [
    k: ø
    case [num]
        when? [=32]  -> k: "␠"
        when? [=127] -> k: "␡"
        else         -> k: to :string to :char num

    prints pad ~"|num|: |k|" 10
    if 1 = num%6 -> print ""
]


AutoTrim,Off ;Allows for whitespace at end of variable to separate converted characters

MessageText := ;The text to display in the final message box.
CurrentASCII := 32 ;Current ASCII number to convert and add to MessageText
ConvertedCharacter := ;Stores the currently converted ASCII code
RowLength := 0 ;Keeps track of the number of converted ASCII numbers in each row

Loop { ;Loops through each ASCII character and makes a list in MessageText
	if CurrentASCII > 127 ;When the current ASCII number goes over 127, terminate the loop
		Break
	if (RowLength = 6) { ;Checks if the row is 6 converted characters long, and if so, inserts a line break (`n)
		MessageText = %MessageText%`n
		RowLength := 0
	}
	if (CurrentASCII = 32) {
		ConvertedCharacter = SPC
	} else {
		if (CurrentASCII = 127) {
			ConvertedCharacter = DEL
		}
		else {
			ConvertedCharacter := Chr(CurrentASCII) ;Converts CurrentASCII number using Chr() and stores it in ConvertedCharacter
		}
	}
	MessageText = %MessageText%%CurrentASCII%: %ConvertedCharacter%`t ;Adds converted ASCII to end of MessageText
	CurrentASCII := CurrentASCII + 1
	RowLength := RowLength + 1
}
MsgBox, % MessageText ;Displays a message box with the ASCII conversion table, from the MessageText variable
return


$ picolisp -'prinl "Hello world!"' -bye
Hello world!


> powershell -Command "Write-Host 'Hello'"
Hello


mkdir -p Tmp; echo "println(\"hello world\");" > Tmp/Tmp.pde; processing-java --sketch="`pwd`/Tmp" --run


$ swipl -g "writeln('hello world')." -t 'halt.'
hello world
$


# syntax: GAWK -f SHOW_ASCII_TABLE.AWK
# syntax: MAWK -f SHOW_ASCII_TABLE.AWK
BEGIN {
    for (i=0; i<16; i++) {
      for (j=32+i; j<128; j+=16) {
        if (j == 32) { x = "SPC" }
        else if (j == 127) { x = "DEL" }
        else { x = sprintf("%c",j) }
        printf("%3d: %-5s",j,x)
      }
      print ""
    }
}


FOR j = 0 TO 15
    FOR i = 32+j TO 127 STEP 16
        PRINT i FORMAT "  %3d - ";
        SELECT i
            CASE 32
                PRINT "Spc";
            CASE 127
                PRINT "Del";
            DEFAULT
                PRINT i FORMAT "%c  "
        ENDSELECT
    NEXT
    PRINT
NEXT


$ echo 'messagerequester("Greetings","hello")' > "dib.pb" && ./pbcompiler dib.pb -e "dib" && ./dib


$ QUACK=$(mktemp); echo "say 'hello'" > $QUACK; quackery $QUACK; rm $QUACK
hello


$ echo 'cat("Hello\n")' | R --slave
Hello


$ racket -e "(displayln \"Hello World\")"
Hello World


$ raku -e 'say "Hello, world!"'
Hello, world!


rebview -vswq --do "print {Hello!} quit"


        ╔══════════════════════════════════════════════╗
        ║                                              ║
        ║  from the MS Window command line  (cmd.exe)  ║
        ║                                              ║
        ╚══════════════════════════════════════════════╝

echo   do j=10  by 20  for 4;   say right('hello',j); end   |   regina


get "libhdr"

let str(n) =
    n=32  -> "%I3: Spc  ",
    n=127 -> "%I3: Del  ",
    "%I3: %C    "

let start() be
    for i=32 to 47 do
    $(  for j=i to 127 by 16 do
            writef(str(j), j, j)
        wrch('*N')
    $)


#include <stdio.h>

int main() {
    int i, j;
    char k[4];
    for (i = 0; i < 16; ++i) {
        for (j = 32 + i; j < 128; j += 16) {
            switch (j) {
                default:  sprintf(k, "%c", j); break;
                case 32:  sprintf(k, "Spc"); break;
                case 127: sprintf(k, "Del"); break;
            }
            printf("%3d : %-3s   ", j, k);
        }
        printf("\n");
    }
    return 0;
}


$ echo 'fn main(){println!("Hello!")}' | rustc -;./rust_out


#include <string>
#include <iomanip>
#include <iostream>

#define HEIGHT        16
#define WIDTH         6
#define ASCII_START   32
#define ASCII_END     128
// ASCII special characters
#define SPACE         32
#define DELETE        127

std::string displayAscii(int ascii) {
  switch(ascii) {
    case SPACE:
      return "Spc";
    case DELETE:
      return "Del";
    default:
      return std::string(1,char(ascii));
  }
}

int main(void) {

  for(int row = 0; row < HEIGHT; ++row) {
    for(int col = 0; col < WIDTH; ++col) {
      int ascii = ASCII_START + row + col*HEIGHT;
      std::cout << std::right << std::setw(3) << ascii << " : " \
        << std::left << std::setw(6) << displayAscii(ascii);
    }
    std::cout << std::endl;
  }
}


using static System.Console;
using static System.Linq.Enumerable;

public class Program
{
    static void Main()
    {
        for (int start = 32; start + 16 * 5 < 128; start++) {
            WriteLine(string.Concat(Range(0, 6).Select(i => $"{start+16*i, 3} : {Text(start+16*i), -6}")));
        }

        string Text(int index) => index == 32 ? "Sp" : index == 127 ? "Del" : (char)index + "";
    }
}


./slate --eval "[inform: 'hello'] ensure: [exit: 0].".


echo 'a output = "Hello, World!";end' | snobol4 -b


echo 'System.print("Hello from Wren!")' > tmp.wren; wren tmp.wren


SHOWASCII
  ; this is 96 characters, so do 6 columns of 16
  for i = 32:1:127 {
    ; get remainder when div by 6, sort columns by remainder 2 3 4 5 0 1
    set rem = i # 6
    if rem = 2 {
      write !
    }

    ; spacing (tabs)
    set x = $case(rem,2:0,3:8,4:16,5:24,0:32,:40)

    ; char to write
    set wrtchr = $case(i,32:"Spc",127:"Del",:$char(i))
    write ?x,$justify(i,3)_": "_wrtchr
  }

  quit


(defn cell [code]
  (let [text (get {32 "Spc", 127 "Del"} code (char code))]
    (format "%3d: %3s" code text)))

(defn ascii-table [n-cols st-code end-code]
  (let [n-cells (inc (- end-code st-code))
        n-rows  (/ n-cells n-cols)
        code    (fn [r c] (+ st-code r (* c n-rows)))
        row-str (fn [r]
                  (clojure.string/join "  "
                                       (map #(cell (code r %))
                                            (range n-cols))))]
    (->> (for [r (range n-rows)]
           (row-str r))
         (clojure.string/join "\n"))))

(defn pr-ascii-table [n-cols st-code end-code]
  (println (ascii-table n-cols st-code end-code)))


echo 'println("Hello World ",5+6)' | zkl


ascii = proc (n: int) returns (string)
    if n=32 then return("Spc")
    elseif n=127 then return("Del")
    else return(string$c2s(char$i2c(n)))
    end
end ascii

start_up = proc ()
    po: stream := stream$primary_output()
    for i: int in int$from_to(32, 47) do
        for j: int in int$from_to_by(i, 127, 16) do
            stream$putright(po, int$unparse(j), 3)
            stream$puts(po, ": ")
            stream$putleft(po, ascii(j), 5)
        end
        stream$putl(po, "")
    end
end start_up


IDENTIFICATION DIVISION.
PROGRAM-ID. CHARSET.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CHARCODE PIC 9(3) VALUE 32.
PROCEDURE DIVISION.
MAIN-PROCEDURE.
PERFORM UNTIL CHARCODE=128
DISPLAY FUNCTION CONCATENATE(
    FUNCTION CONCATENATE(
        CHARCODE,
        " : "
    ),
    FUNCTION CONCATENATE(
        FUNCTION CHAR(CHARCODE),
        "   "
    )
)
WITH NO ADVANCING
ADD 1 TO CHARCODE
END-PERFORM.
END PROGRAM CHARSET.


100 PRINT CHR$(147);:REM CLEAR SCREEN
110 PRINT CHR$(14);:REM CHARACTER SET 2
120 PRINT "COMMODORE 64 - BASIC V2"
130 PRINT "CHARACTER SET 2"
140 PRINT
150 FOR R=0 TO 15
160 FOR C=0 TO 5
170 A=32+R+C*16
180 PRINT RIGHT$("  "+STR$(A),4);":";CHR$(A);
190 NEXT C
200 PRINT
210 NEXT R


(setq startVal 32)
(setq endVal 127)
(setq cols 6)

(defun print-val (val) "Prints the value for that ascii number"
	(cond
		((= val 32) (format t " 32: SPC "))
		((= val 127) (format t "127: DEL~%"))
		((and (zerop (mod (- val startVal) cols)) (< val 100)) (format t "~% ~d: ~a   " val (int-char val)))
		((and (zerop (mod (- val startVal) cols)) (>= val 100)) (format t "~%~d: ~a   " val (int-char val)))
		((< val 100) (format t " ~d:  ~a   " val (int-char val)))
		((>= val 100) (format t "~d:  ~a   " val (int-char val)))
		(t nil)))

        (defun get-range (lower upper) "Returns a list of range lower to upper"
	(if (> lower upper) '() (cons lower (get-range (+ 1 lower) upper))))

(mapcar #'print-val (get-range startVal endVal))


include "cowgol.coh";

# Print number with preceding space if <100 and trailing colon
sub print_num(n: uint8) is
    if n < 100 then print_char(' '); end if;
    print_i8(n);
    print(": ");
end sub;

# Print character / Spc / Del padded to 5 spaces
sub print_ch(c: uint8) is
    if c == ' ' then print("Spc  ");
    elseif c == 127 then print("Del  ");
    else
        print_char(c);
        print("    ");
    end if;
end sub;

var c: uint8 := 32;
loop
    print_num(c);
    print_ch(c);
    if c == 127 then
        break;
    end if;
    c := c + 16;
    if c > 127 then
        print_nl();
        c := c - 95;
    end if;
end loop;
print_nl();


import std.stdio;

void main() {
    for (int i = 0; i < 16; ++i) {
        for (int j = 32 + i; j < 128; j += 16) {
            switch (j) {
                case 32:
                    writef("%3d : Spc   ", j);
                    break;
                case 127:
                    writef("%3d : Del   ", j);
                    break;
                default:
                    writef("%3d : %-3s     ", j, cast(char)j);
                    break;
            }
        }
        writeln;
    }
}


program Show_Ascii_table;

{$APPTYPE CONSOLE}

var
  i, j: Integer;
  k: string;

begin
  for i := 0 to 15 do
  begin
    j := 32 + i;
    while j < 128 do
    begin
      case j of
        32:
          k := 'Spc';
        127:
          k := 'Del';
      else
        k := chr(j);
      end;
      Write(j: 3, ' : ', k: 3, '   ');
      inc(j, 16);
    end;
    Writeln;
  end;
  Readln;
end.


asciiTable
=LAMBDA(i,
    justifyRight(3)(" ")(i) & ": " & (
        justifyRight(
           3
        )(" ")(
            IF(32 = i,
                "Spc",
                IF(127 = i,
                    "Del",
                    CHAR(i)
                )
            )
        )
    )
)(
    SEQUENCE(16, 6, 32, 1)
)


USING: combinators formatting io kernel math math.ranges
pair-rocket sequences ;
IN: rosetta-code.ascii-table

: row-values ( n -- seq ) [ 32 + ] [ 112 + ] bi 16 <range> ;

: ascii>output ( n -- str )
    { 32 => [ "Spc" ] 127 => [ "Del" ] [ "" 1sequence ] } case ;

: print-row ( n -- )
    row-values [ dup ascii>output "%3d : %-3s   " printf ] each nl ;

: print-ascii-table ( -- ) 16 <iota> [ print-row ] each ;

MAIN: print-ascii-table


DECIMAL
: ###: ( c -- ) 3 .R ." : " ;

: .CHAR  ( c -- )
        DUP
        CASE
         BL OF  ###: ." spc"  ENDOF
        127 OF  ###: ." del"  ENDOF
            DUP ###: EMIT  2 SPACES
        ENDCASE
        3 SPACES ;

: .ROW ( n2 n1 -- )
       CR DO   I .CHAR   16 +LOOP ;

: ASCII.TABLE ( -- )
        16 0 DO   113 I +   32 I +  .ROW     LOOP ;


       PROGRAM ASCTBL  ! show the ASCII characters from 32-127
       IMPLICIT NONE
       INTEGER I, J
       CHARACTER*3 H

  10   FORMAT (I3, ':', A3, '   ', $)
  20   FORMAT ()
       DO J = 0, 15, +1
         DO I = 32+J, 127, +16
           IF (I > 32 .AND. I < 127) THEN
             H = ' ' // ACHAR(I) // ' '
           ELSE IF (I .EQ. 32) THEN
             H = 'Spc'
           ELSE IF (I .EQ. 127) THEN
             H = 'Del'
           ELSE
             STOP 'bad value of i'
           END IF
           PRINT 10, I, H
         END DO
         PRINT 20
       END DO

       END


function getasc( n as unsigned byte ) as string
    if n=32 then return "Spc"
    if n=127 then return "Del"
    return chr(n)+"  "
end function

function padto( i as ubyte, j as integer ) as string
    return wspace(i-len(str(j)))+str(j)
end function

dim as unsigned byte r, c, n
dim as string disp

for r = 0 to 15
    disp = ""
    for c = 0 to 5
        n = 32 + 6*r + c
        disp = disp + padto(3, n) + ": " + getasc(n) + "    "
    next c
    print disp
next r


// The FPC (FreePascal compiler) discards the program header
// (except in ISO-compliant “compiler modes”).
program showAsciiTable(output);

const
	columnsTotal = 6;

type
	// The hash indicates a char-data type.
	asciiCharacter = #32..#127;
	asciiCharacters = set of asciiCharacter;

var
	character: asciiCharacter;
	characters: asciiCharacters;
	column, line: integer;
begin
	// characters needs to be initialized,
	// because the next `include` below
	// will _read_ the value `characters`.
	// Reading _unintialized_ values, however,
	// is considered bad practice in Pascal.
	characters := [];
	// `div` denotes integer division in Pascal,
	// that means the result will be an _integer_-value.
	line := (ord(high(asciiCharacter)) - ord(low(asciiCharacter)))
		div columnsTotal + 1;
	// Note: In Pascal for-loop limits are _inclusive_.
	for column := 0 to columnsTotal do
	begin
		// This is equivalent to
		//   characters := characters + […];
		// i.e. the union of two sets.
		include(characters, chr(ord(low(asciiCharacter)) + column * line));
	end;

	for line := line downto 1 do
	begin
		// the for..in..do statement is an Extended Pascal extension
		for character in characters do
		begin
			// `:6` specifies minimum width of argument
			// [only works for write/writeLn/writeStr]
			write(ord(character):6, ' : ', character);
		end;
		// emit proper newline character on `output`
		writeLn;

		// `characters` is evaluated prior entering the loop,
		// not every time an iteration finished.
		for character in characters do
		begin
			// These statements are equivalent to
			//   characters := characters + [character];
			//   characters := characters - [succ(character)];
			// respectively, but shorter to write,
			// i.e. less susceptible to spelling mistakes.
			exclude(characters, character);
			include(characters, succ(character));
		end;
	end;
end.


a = ["32 Space"]
for i = 33 to 126
   a.push["$i " + char[i]]
a.push["127 Delete"]

println[formatTableBoxed[columnize[a,8].transpose[], "left"]]


include "NSLog.incl"

local fn ASCIITable as CFStringRef
'~'1
NSinteger   i
CFStringRef temp

CFMutableStringRef mutStr = fn MutableStringWithCapacity( 0 )
for i = 32 to 127
temp = fn StringWithFormat( @"%c", i )
if i ==  32 then temp = @"Spc"
if i == 127 then temp = @"Del"
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-1d : %@\n", i, temp ) )
next

CFArrayRef colArr = fn StringComponentsSeparatedByString( mutStr, @"\n" )
MutableStringSetString( mutStr, @"" )
for i = 0 to 15
ObjectRef col0 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i      ) )
ObjectRef col1 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 16 ) )
ObjectRef col2 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 32 ) )
ObjectRef col3 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 48 ) )
ObjectRef col4 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 64 ) )
ObjectRef col5 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 80 ) )
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-10s %-10s %-10s %-10s %-10s %-10s\n", col0, col1, col2, col3, col4, col5 ) )
next
end fn = fn StringWithString( mutStr )

NSLog( @"%@", fn ASCIITable )

HandleEvents


package main

import "fmt"

func main() {
    for i := 0; i < 16; i++ {
        for j := 32 + i; j < 128; j += 16 {
            k := string(j)
            switch j {
            case 32:
                k = "Spc"
            case 127:
                k = "Del"
            }
            fmt.Printf("%3d : %-3s   ", j, k)
        }
        fmt.Println()
    }
}


class ShowAsciiTable {
    static void main(String[] args) {
        for (int i = 32; i <= 127; i++) {
            if (i == 32 || i == 127) {
                String s = i == 32 ? "Spc" : "Del"
                printf("%3d: %s ", i, s)
            } else {
                printf("%3d: %c   ", i, i)
            }
            if ((i - 1) % 6 == 0) {
                println()
            }
        }
    }
}


import Data.Char (chr)
import Data.List (transpose)
import Data.List.Split (chunksOf)
import Text.Printf (printf)

----------------------- ASCII TABLE ----------------------

asciiTable :: String
asciiTable =
  unlines $
    (printf "%-12s" =<<)
      <$> transpose
        (chunksOf 16 $ asciiEntry <$> [32 .. 127])

asciiEntry :: Int -> String
asciiEntry n
  | null k = k
  | otherwise = concat [printf "%3d" n, " : ", k]
  where
    k = asciiName n

asciiName :: Int -> String
asciiName n
  | 32 > n = []
  | 127 < n = []
  | 32 == n = "Spc"
  | 127 == n = "Del"
  | otherwise = [chr n]

--------------------------- TEST -------------------------
main :: IO ()
main = putStrLn asciiTable


100 TEXT 80
110 FOR R=0 TO 15
120   FOR C=32+R TO 112+R STEP 16
130     PRINT USING "###":C;:PRINT ": ";CHR$(C),
140   NEXT
150   PRINT
160 NEXT


public class ShowAsciiTable {

    public static void main(String[] args) {
        for ( int i = 32 ; i <= 127 ; i++ ) {
            if ( i == 32 || i == 127 ) {
                String s = i == 32 ? "Spc" : "Del";
                System.out.printf("%3d: %s ", i, s);
            }
            else {
                System.out.printf("%3d: %c   ", i, i);
            }
            if ( (i-1) % 6 == 0 ) {
                System.out.println();
            }
        }
    }

}


(() => {

    "use strict";

    // ------------------- ASCII TABLE -------------------

    // asciiTable :: String
    const asciiTable = () =>
        transpose(
            chunksOf(16)(
                enumFromTo(32)(127)
                .map(asciiEntry)
            )
        )
        .map(
            xs => xs.map(justifyLeft(12)(" "))
            .join("")
        )
        .join("\n");

    // asciiEntry :: Int -> String
    const asciiEntry = n => {
        const k = asciiName(n);

        return "" === k ? (
            ""
        ) : `${justifyRight(4)(" ")(n.toString())} : ${k}`;
    };

    // asciiName :: Int -> String
    const asciiName = n =>
        32 > n || 127 < n ? (
            ""
        ) : 32 === n ? (
            "Spc"
        ) : 127 === n ? (
            "Del"
        ) : chr(n);

    // ---------------- GENERIC FUNCTIONS ----------------

    // chr :: Int -> Char
    const chr = x =>
        // The character at unix code-point x.
        String.fromCodePoint(x);

    // chunksOf :: Int -> [a] -> [[a]]
    const chunksOf = n => {
        // xs split into sublists of length n.
        // The last sublist will be short if n
        // does not evenly divide the length of xs .
        const go = xs => {
            const chunk = xs.slice(0, n);

            return 0 < chunk.length ? (
                [chunk].concat(
                    go(xs.slice(n))
                )
            ) : [];
        };

        return go;
    };

    // enumFromTo :: Int -> Int -> [Int]
    const enumFromTo = m =>
        n => Array.from({
            length: 1 + n - m
        }, (_, i) => m + i);

    // justifyLeft :: Int -> Char -> String -> String
    const justifyLeft = n =>
        // The string s, followed by enough padding (with
        // the character c) to reach the string length n.
        c => s => n > s.length ? (
            s.padEnd(n, c)
        ) : s;

    // justifyRight :: Int -> Char -> String -> String
    const justifyRight = n =>
        // The string s, preceded by enough padding (with
        // the character c) to reach the string length n.
        c => s => Boolean(s) ? (
            s.padStart(n, c)
        ) : "";

    // transpose :: [[a]] -> [[a]]
    const transpose = rows =>
        // The columns of the input transposed
        // into new rows.
        // This version assumes input rows of even length.
        0 < rows.length ? rows[0].map(
            (x, i) => rows.flatMap(
                v => v[i]
            )
        ) : [];

    // MAIN ---
    return asciiTable();
})();


#!/usr/bin/env jsish

/* Show ASCII table, -showAll true to include control codes */
function showASCIITable(args:array|string=void, conf:object=void) {
    var options = {           // Rosetta Code, Show ASCII table
        rootdir      :'',      // Root directory.
        showAll      : false  // include control code labels if true
    };
    var self = {};
    parseOpts(self, options, conf);

    function main() {
        var e;
        var first = (self.showAll) ? 0 : 2;
        var filler = '='.repeat(19 + ((first) ? 0 : 9));
        puts(filler, "ASCII table", filler + '=');
        var labels = [
            'NUL', 'SOH', 'STX', 'ETX', 'EOT', 'ENQ', 'ACK', 'BEL',
            'BS ', 'HT ', 'LF ', 'VT ', 'FF ', 'CR ', 'SO ', 'SI ',
            'DLE', 'DC1', 'DC2', 'DC3', 'DC4', 'NAK', 'SYN', 'ETB',
            'CAN', 'EM ', 'SUB', 'ESC', 'FS ', 'GS ', 'RS ', 'US '];
        var table = new Array(128);
        for (e = 0; e < 32; e++) table[e] = labels[e];
        for (e = 32; e < 127; e++) table[e] = ' ' + Util.fromCharCode(e) + ' ';
        table[32] = 'SPC';
        table[127] = 'DEL';

        for (var row = 0; row < 16; row++) {
            for (var col = first; col < 8; col++) {
                e = row + col * 16;
                printf('%03d %s  ', e, table[e]);
            }
            printf('\n');
        }
    }
    return main();
}

provide(showASCIITable, 1);

if (isMain()) {
    if (Interp.conf('unitTest')) showASCIITable('', {showAll:true});
    else runModule(showASCIITable);
}

/*
=!EXPECTSTART!=
============================ ASCII table =============================
000 NUL  016 DLE  032 SPC  048  0   064  @   080  P   096  `   112  p
001 SOH  017 DC1  033  !   049  1   065  A   081  Q   097  a   113  q
002 STX  018 DC2  034  "   050  2   066  B   082  R   098  b   114  r
003 ETX  019 DC3  035  #   051  3   067  C   083  S   099  c   115  s
004 EOT  020 DC4  036  $   052  4   068  D   084  T   100  d   116  t
005 ENQ  021 NAK  037  %   053  5   069  E   085  U   101  e   117  u
006 ACK  022 SYN  038  &   054  6   070  F   086  V   102  f   118  v
007 BEL  023 ETB  039  '   055  7   071  G   087  W   103  g   119  w
008 BS   024 CAN  040  (   056  8   072  H   088  X   104  h   120  x
009 HT   025 EM   041  )   057  9   073  I   089  Y   105  i   121  y
010 LF   026 SUB  042  *   058  :   074  J   090  Z   106  j   122  z
011 VT   027 ESC  043  +   059  ;   075  K   091  [   107  k   123  {
012 FF   028 FS   044  ,   060  <   076  L   092  \   108  l   124  |
013 CR   029 GS   045  -   061  =   077  M   093  ]   109  m   125  }
014 SO   030 RS   046  .   062  >   078  N   094  ^   110  n   126  ~
015 SI   031 US   047  /   063  ?   079  O   095  _   111  o   127 DEL
=!EXPECTEND!=
*/


# Pretty printing
def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .;

def nwise($n):
  def n: if length <= $n then . else .[0:$n] , (.[$n:] | n) end;
  n;

def table($ncols; $colwidth):
  nwise($ncols) | map(lpad($colwidth)) | join(" ");

# transposed table
def ttable($rows):
  [nwise($rows)] | transpose[] | join(" ");

# Representation of control characters, etc
def humanize:
  def special:
  { "0": "NUL",    "7": "BEL",    "8": "BKS",
    "9": "TAB",   "10": "LF ",   "13": "CR ",
   "27": "ESC",  "127": "DEL",  "155": "CSI" };

  if . < 32 or . == 127 or . == 155
  then (special[tostring] // "^" + ([64+.]|implode))
  elif . > 127 and . < 160 then "\\\(.+72|tostring)"
  else [.] | implode
  end
  | lpad(4) ;


// Version 1.2.60

fun main(args: Array<String>) {
    for (i in 0..15) {
        for (j in 32 + i..127 step 16) {
            val k = when (j) {
                32   -> "Spc"
                127  -> "Del"
                else -> j.toChar().toString()
            }
            System.out.printf("%3d : %-3s   ", j, k)
        }
        println()
    }
}


10 mode 1:defint a-z
20 for x=1 to 6
30 for y=1 to 16
40 n=16*(x-1)+y+31
50 locate 6*(x-1)+1,y
60 print using "###";n;
70 print " ";chr$(n);
80 next
90 next


-- map of character values to desired representation
local chars = setmetatable({[32] = "Spc", [127] = "Del"}, {__index = function(_, k) return string.char(k) end})

-- row iterator
local function iter(s,a)
  a = (a or s) + 16
  if a <= 127 then return a, chars[a] end
end

-- print loop
for i = 0, 15 do
   for j, repr in iter, i+16 do
      io.write(("%3d : %3s    "):format(j, repr))
   end
   io.write"\n"
end


Function ProduceAscii$ {
	Document Ascii$="\"
	DelUnicode$=ChrCode$(0x2421)
	j=2
	Print Ascii$;
	For i=0 to 15
	Print Hex$(i, .5);
	Ascii$=Hex$(i, .5)
	Next
	For i=32 to 126
		If pos>16 then
			Ascii$={
			}+Hex$(j, .5)
			Print : Print Hex$(j, .5);: j++
		End if
		Print Chr$(i);
		Ascii$=Chr$(i)
	Next
	Print DelUnicode$
	=Ascii$+DelUnicode$+{
	}
}
Clipboard ProduceAscii$()


StringRiffle[[email protected]@@Transpose[Partition[ToString[#]<>": "<>Switch[#,32,"Spc  ",127,"Del  ",_,FromCharacterCode[#]<>"    "]&/@Range[32,127],16]],"\n"]


// Prints ASCII table
// Note changing the values of startChar and endChar will print
// a flexible table in that range

startChar = 32
endChar = 127
characters = []

for i in range(startChar, endChar)
    addString = char(i) + "  "
    if i == 32 then addString = "SPC"
    if i == 127 then addString = "DEL"
    characters.push addString
end for

for i in characters.indexes
    iNum = i + startChar
    iChar = "     " + str(iNum)
    characters[i] = iChar[-5:] + " : " + characters[i]
end for

columns = 6
line = ""
col = 0
for out in characters
    col = col + 1
    line = line + out
    if col == columns then
        print line
        line = ""
        col = 0
    end if
end for
if line then print line // final check for odd incomplete line output


k = ""
for i in range(0, 15)
	for j in range(32 + i, 127, 16)
		if j = 32
			k = "Spc"
		else if j = 127
			k = "Del"
		else
			k = chr(j)
		end
		print format("%3d : %-3s   ", j, k)
	end
	println
end


import strformat

for i in 0..15:
  for j in countup(32 + i, 127, step = 16):
    let k = case j
            of 32: "Spc"
            of 127: "Del"
            else: $chr(j)
    write(stdout, fmt"{j:3d} : {k:<6s}")
  write(stdout, "\n")


uses console
int i,j
string c
for i=32 to 127
  select case i
    case 32 : c="spc"
    case 127: c="del"
    case else c=chr i
  end select
  print i ": " c tab
  j++
  if j = 8 'columns
    print cr
    j=0
  endif
next
pause


use charnames ':full';
binmode STDOUT, ':utf8';

sub glyph {
    my($n) = @_;
    if    ($n < 33) { chr 0x2400 + $n } # display symbol names for invisible glyphs
    elsif ($n==124) { '<nowiki>|</nowiki>' }
    elsif ($n==127) { 'DEL' }
    else            { chr $n }
}

print qq[{|class="wikitable" style="text-align:center;background-color:hsl(39, 90%, 95%)"\n];

for (0..127) {
    print qq[|-\n] unless $_ % 16;;
        printf qq[|%d
0x%02X
<big><big title="%s">%s</big></big>\n],
                $_, $_, charnames::viacode($_), glyph($_);
    }
}
print qq[|}\n];


with javascript_semantics

sequence ascii = {}
for ch=32 to 127 do
    ascii = append(ascii,sprintf("%4d (#%02x): %c ",ch))
end for
puts(1,substitute(join_by(ascii,16,6),"\x7F","del"))


<?php

echo '+' . str_repeat('----------+', 6), PHP_EOL;
for ($j = 0 ; $j < 16 ; $j++) {
    for ($i = 0 ; $i < 6 ; $i++) {
        $val = 32 + $i * 16 + $j;
        switch ($val) {
            case  32: $chr = 'Spc';      break;
            case 127: $chr = 'Del';      break;
            default:  $chr = chr($val) ; break;
        }
        echo sprintf('| %3d: %3s ', $val, $chr);
    }
    echo '|', PHP_EOL;
}
echo '+' . str_repeat('----------+', 6), PHP_EOL;


100H: /* SHOW AN ASCII TABLE FROM 32 TO 127                                 */
   /* CP/M BDOS SYSTEM CALL                                                 */
   BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5; END;
   /* I/O ROUTINES                                                          */
   PR$CHAR:   PROCEDURE( C ); DECLARE C BYTE;    CALL BDOS( 2, C );  END;
   PR$STRING: PROCEDURE( S ); DECLARE S ADDRESS; CALL BDOS( 9, S );  END;
   PR$BYTE: PROCEDURE( N );
      DECLARE N BYTE;
      DECLARE V BYTE;
      V = N MOD 100;
      CALL PR$CHAR( ' ' );
      CALL PR$CHAR( '0' + ( N  / 100 ) );
      CALL PR$CHAR( '0' + ( V  /  10 ) );
      CALL PR$CHAR( '0' + ( V MOD 10 ) );
   END PR$BYTE;
   /* ASCII TABLE                                                           */
   DECLARE C BYTE;
   DO C = 32 TO 127;
      CALL PR$BYTE( C );
      CALL PR$STRING( .': $' );
      IF      C =  32 THEN CALL PR$STRING( .'SPC$' );
      ELSE IF C = 127 THEN CALL PR$STRING( .'DEL$' );
      ELSE DO;
         CALL PR$CHAR( ' ' );
         CALL PR$CHAR(  C  );
         CALL PR$CHAR( ' ' );
      END;
      IF ( ( C - 31 ) MOD 6 ) = 0 THEN CALL PR$STRING( .( 0DH, 0AH, '$' ) );
   END;
EOF


ascii :-
    forall(between(32, 47, N), row(N)).

row(N) :- N > 127, nl, !.
row(N) :-
    code(N),
    ascii(N),
    Nn is N + 16,
    row(Nn).

code(N) :- N < 100, format('  ~d : ', N).
code(N) :- N >= 100, format(' ~d : ', N).

ascii(32) :- write(' Spc    '), !.
ascii(127) :- write(' Del   '), !.
ascii(A) :- char_code(D,A), format(' ~w      ', D).


If OpenConsole("Show_Ascii_table: rosettacode.org")
  Define r.i, c.i
  For r=0 To 15
    For c=32+r To 112+r Step 16
      Print(RSet(Str(c),3)+" : ")
      Select c
        Case 32
          Print("Spc")
        Case 127
          Print("Del")
        Default
          Print(LSet(Chr(c),3))
      EndSelect
      Print(Space(3))
    Next
    PrintN("")
  Next
  Input()
EndIf


for i in range(16):
    for j in range(32+i, 127+1, 16):
        if j == 32:
            k = 'Spc'
        elif j == 127:
            k = 'Del'
        else:
            k = chr(j)
        print("%3d : %-3s" % (j,k), end="")
    print()


DIM s AS STRING

FOR i% = 32 TO 47
    FOR j% = i% TO i% + 80 STEP 16
        SELECT CASE j%
            CASE 32
                s$ = "Spc"
            CASE 127
                s$ = "Del"
            CASE ELSE
                s$ = CHR$(j%)
        END SELECT
        PRINT USING "###: \   \"; j%; s$;
    NEXT j%
    PRINT
NEXT i%


  [ dup 32  = iff
      [ drop say 'spc' ] done
    dup 127 = iff
      [ drop say 'del' ] done
    emit sp sp ]                    is echoascii  ( n --> )

  [ dup echo say ': '
    dup echoascii
    84 < 3 + times sp ]             is echoelt    ( n --> )

  [ sp 81 times
      [ dup i^ + echoelt 16 step ]
    drop cr ]                       is echorow    ( n --> )

  [ 16 times [ i^ 32 + echorow ] ]  is echotable  (   --> )

  echotable


chr <- function(n) {
  rawToChar(as.raw(n))
}

idx <- 32
while (idx < 128) {
  for (i in 0:5) {
	num <- idx + i
	if (num<100) cat(" ")
        cat(num,": ")
	if (num == 32) { cat("Spc "); next }
        if (num == 127) { cat("Del "); next }
	cat(chr(num),"  ")
  }
  idx <- idx + 6
  cat("\n")
}


#lang racket

(for ([i (in-range 16)])
  (for ([j (in-range 6)])
    (define n (+ 32 (* j 16) i))
    (printf "~a : ~a"
            (~a n #:align 'right #:min-width 3)
            (~a (match n
                  [32 "SPC"]
                  [127 "DEL"]
                  [_ (integer->char n)]) #:min-width 5)))
  (newline))


sub glyph ($_) {
    when * < 33 { (0x2400 + $_).chr } # display symbol names for invisible glyphs
    when 127    { '␡' }
    default     { .chr }
}

say '{|class="wikitable" style="text-align:center;background-color:hsl(39, 90%, 95%)"';

for (^128).rotor(16) -> @row {
    say '|-';
    printf(q[|%d
0x%02X
<big><big title="%s">%s</big></big>] ~ "\n",
      $_, $_, .&glyph.uniname.subst('SYMBOL FOR ', ''),
      .&glyph.subst('|', '<nowiki>|</nowiki>')) for @row;
}

say '|}';


Red ["ASCII table"]

repeat i 16 [
    repeat j 6 [
        n: j - 1 * 16 + i + 31
        prin append pad/left n 3 ": "
        prin pad switch/default n [
            32 ["spc"]
            127 ["del"]
        ] [to-char n] 4
    ]
    prin newline
]


/*REXX program displays an  ASCII  table of characters  (within a  16x16  indexed grid).*/
parse upper version !ver .                       /*some REXXes can't display '1b'x glyph*/
!pcRexx= 'REXX/PERSONAL'==!ver | "REXX/PC"==!ver /*is this  PC/REXX  or  REXX/Personal? */
          func= '  nul soh stx etx eot enq ack bel  bs tab  lf  vt  ff  cr  so  si  '  ||,
                "  dle dc1 dc2 dc3 dc4 nak syn etb can  em eof esc  fs  gs  rs  us  "
@.=
@.1= "x'07'    x'08'       x'09'     x'0a'      x'0d'      x'1a'      x'1b'     x'20'"
@.2= "bel      b/s         tab       l/f        c/r        eof        esc       bla"
@.3= "bell     backspace   tabchar   linefeed   carriage   end-of-    escape    blank"
@.4= "                                          return     file"
@.5= copies('≈', 79)
            do a=1  for 8;   say @.a             /*display header info  (abbreviations).*/
            end   /*a*/                          /*also included are three blank lines. */
b= ' ';         hdr= left(b, 7)                  /*prepend blanks to HDR  (indentation).*/
call xhdr                                        /*construct a  top  index for the grid.*/
call grid '╔',  "╤",  '╗',  "═══"                /*construct & display bottom of a cell.*/
iidx= left(b, length(hdr) - 4 )                  /*the length of the indentation of idx.*/
cant= copies('═', 3)                             /*can't show a character with this REXX*/
                                                 /* [↓]  construct a sixteen-row grid.  */
   do j=0  by 16  for 16;  idx= left(d2x(j),1,2) /*prepend an index literal for the grid*/
   _= iidx idx b;           _h= iidx "   "       /*an index and indent; without an index*/
   sep= '║'                                      /*assign a character to cell separator.*/
             do #=j  to j+15;               chr= center( d2c(#), 3)   /*true char glyph.*/
             if #>6 & #<11  |  #==13   then chr= cant         /*can't show these glyphs.*/
   /*esc*/   if #==27 then if !pcRexx  then chr= cant         /*  "     "  this  glyph. */
                                       else chr= center( d2c(#), 3)   /*true char glyph.*/
             if # <32 then _h= _h || sep || right(word(func, #+1), 3) /*show a function.*/
             if #==32 then chr= 'bla'            /*spell out (within 3 chars) a "BLAnk".*/
             if # >31 then _h=                   /*Above a blank?  Then nullify 3rd line*/
             _= _ || sep || chr;     sep= '│'    /*append grid cell; use a new sep char.*/
             end   /*#*/
   if _h\==''  then say _h"║ "                   /*append the  last grid cell character.*/
   say _'║ '   idx                               /*append an   index   to the grid line.*/
   if j\==240  then call grid '╟',"┼",'╢',"───"  /*construct & display most cell bottoms*/
   end   /*j*/

call grid '╚',  "╧",  '╝',  "═══"                /*construct & display last cell bottom.*/
call xhdr                                        /*construct a bottom index for the grid*/
exit                                             /*stick a fork in it,  we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
xhdr: say; _= hdr;  sep= b;   do k=0  for 16; _=_||b d2x(k)b;  end;    say _; say;  return
grid: arg $1,$2,$3,$4; _=hdr; do 16;  _=_ || $1 || $4;  $1= $2;  end;  say _ || $3; return


# Project : Show Ascii table

load "guilib.ring"
load "stdlib.ring"

decarr = newlist(16,6)
ascarr = newlist(16,6)

new qapp
        {
        win1 = new qwidget() {
                  setwindowtitle("Show Ascii table")
                  setgeometry(100,100,800,600)
                  for n = 1 to 16
                       for m = 1 to 6
                            decarr[n][m] = new qpushbutton(win1) {
                                                  x = 150+m*60
                                                  y = 30 + n*30
                                                  ind = string((m-1)*16+n+31)
                                                  setgeometry(x,y,30,30)
                                                  settext(ind)
                                                  }
                       next
                  next
                  for n = 1 to 16
                       for m = 1 to 6
                            ascarr[n][m] = new qpushbutton(win1) {
                                                  x = 180+m*60
                                                  y = 30 + n*30
                                                  ind = (m-1)*16+n+31
                                                  setgeometry(x,y,30,30)
                                                  if ind = 32
                                                     settext("Spc")
                                                     loop
                                                  ok
                                                  if ind = 127
                                                     settext("Del")
                                                     loop
                                                  ok
                                                  settext(char(ind))
                                                  }
                       next
                  next
                  show()
        }
        exec()
        }


chars = (32..127).map do |ord|
  k = case ord
    when 32  then "␠"
    when 127 then "␡"
    else ord.chr
  end
  "#{ord.to_s.ljust(3)}: #{k}"
end

chars.each_slice(chars.size/6).to_a.transpose.each{|s| puts s.join("  ")}


object AsciiTable extends App {
  val (strtCharVal, lastCharVal, nColumns) = (' '.toByte, '\u007F'.toByte, 6)
  require(nColumns % 2 == 0, "Number of columns must be even.")

  val nChars = lastCharVal - strtCharVal + 1
  val step = nChars / nColumns
  val threshold = strtCharVal + (nColumns - 1) * step

  def indexGen(start: Byte): LazyList[Byte] =
    start #:: indexGen(
      (if (start >= threshold) strtCharVal + start % threshold + 1 else start + step).toByte
    )

  def k(j: Byte): Char = j match {
    case `strtCharVal` => '\u2420'
    case 0x7F => '\u2421'
    case _ => j.toChar
  }

  indexGen(strtCharVal)
    .take(nChars)
    .sliding(nColumns, nColumns)
    .map(_.map(byte => f"$byte%3d : ${k(byte)}"))
    .foreach(line => println(line.mkString("  ")))
}


$ include "seed7_05.s7i";

const proc: main is func
  local
    var integer: row is 0;
    var integer: column is 0;
    var integer: number is 0;
  begin
    for row range 0 to 15 do
      for column range 0 to 5 do
        number := 32 + 16 * column + row;
        write(number lpad 3 <& " : ");
        case number of
          when {32}:  write("Spc  ");
          when {127}: write("Del  ");
          otherwise:  write(chr(number) <& "    ");
        end case;
      end for;
      writeln;
    end for;
  end func;


con
  _clkmode = xtal1+pll16x
  _clkfreq = 80_000_000

obj
  ser : "FullDuplexSerial"

pub main | i, j

  ser.start(31, 30, 0, 115200)

  repeat i from 0 to 15
    repeat j from i + 32 to 127 step 16
      if j < 100
        ser.tx(32)
      ser.dec(j)
      ser.str(string(": "))
      case j
        32:
          ser.str(string("SPC"))
        127:
          ser.str(string("DEL"))
        other:
          ser.tx(j)
          ser.str(string("  "))
      ser.str(string("  "))
    ser.str(string(13, 10))

  waitcnt(_clkfreq + cnt)
  ser.stop


fun Table  n 127 =  " 127: 'DEL'\n"
  | Table  0   x =  "\n" ^ (Table 10 x)
  | Table  n   x =  (StringCvt.padLeft #" " 4 (Int.toString x)) ^ ": '" ^ (str (chr x)) ^ "' " ^ ( Table (n-1) (x+1)) ;

print (Table 10 32) ;


for {set i 0} {$i < 16} {incr i} {
    for {set j $i} {$j < 128} {incr j 16} {
        if {$j <= 31} {
            continue                    ;# don't show values 0 - 31
        } elseif {$j ==  32} { set x "SP"
        } elseif {$j == 127} { set x "DEL"
        } else { set x [format %c $j] }
        puts -nonewline [format "%3d: %-5s" $j $x]
    }
    puts ""
}


Public Sub ascii()
    Dim s As String, i As Integer, j As Integer
    For i = 0 To 15
        For j = 32 + i To 127 Step 16
            Select Case j
                Case 32: s = "Spc"
                Case 127: s = "Del"
                Case Else: s = Chr(j)
            End Select
            Debug.Print Tab(10 * (j - 32 - i) / 16); Spc(3 - Len(CStr(j))); j & ": " & s;
        Next j
        Debug.Print vbCrLf
    Next i
End Sub


Imports System.Console
Imports System.Linq.Enumerable

Module Program
    Sub Main()
        Dim Text = Function(index As Integer) If(index = 32, "Sp", If(index = 127, "Del", ChrW(index) & ""))

        Dim start = 32
        Do
            WriteLine(String.Concat(Range(0, 6).Select(Function(i) $"{start + 16 * i, -3} : {Text(start + 16 * i), -6}")))
            start += 1
        Loop While start + 16 * 5 < 128
    End Sub
End Module


import "/fmt" for Fmt

for (i in 0...16) {
    var j = 32 + i
    while (j < 128) {
        var k = "%(String.fromByte(j))"
        if (j == 32) {
            k = "Spc"
        } else if (j == 127) {
            k = "Del"
        }
        System.write("%(Fmt.d(3, j)) : %(Fmt.s(-3, k))   ")
        j = j + 16
    }
    System.print()
}


int Hi, Lo;
[SetHexDigits(2);
Text(0, "     ");
for Hi:= 2 to 7 do
        [HexOut(0, Hi*16);  Text(0, "    ")];
CrLf(0);
for Lo:= 0 to $F do
        [HexOut(0, Lo);  Text(0, "   ");
        for Hi:= 2 to 7 do
                [ChOut(0, Hi*16+Lo);  Text(0, "     ")];
        CrLf(0);
        ];
]


const width=9;
println("  ",[0..width].pump(String,"%4d".fmt));
[30..127].pump("".println,T(Void.Read,width,False), // don't fail on short lines
    fcn(a,b,c){
       String("%3d: ".fmt(a),
       vm.arglist.pump(String,"toChar", // parameters (ints) to list to text
          T("replace","\x1e",""),T("replace","\x1f",""),  // 30,31
          T("replace"," ","spc"),T("replace","\x7f","del"), "%-4s".fmt)
       )
    })


F a(v)
   print(‘  ## Called function a(#.)’.format(v))
   R v

F b(v)
   print(‘  ## Called function b(#.)’.format(v))
   R v

L(i) (0B, 1B)
   L(j) (0B, 1B)
      print("\nCalculating: x = a(i) and b(j)")
      V x = a(i) & b(j)
      print(‘Calculating: y = a(i) or  b(j)’)
      V y = a(i) | b(j)


;DEFINE 0 AS FALSE, $FF as true.
False equ 0
True equ 255
Func_A:
	;input: accumulator = value to check. 0 = false, nonzero = true.
	;output: 0 if false, 255 if true. Also prints the truth value to the screen.
	;USAGE: LDA val JSR Func_A
	BEQ .falsehood
	load16 z_HL,BoolText_A_True ;lda #<BoolText_A_True sta z_L lda #>BoolText_A_True sta z_H
	jsr PrintString
	jsr NewLine
	LDA #True
	rts
.falsehood:
	load16 z_HL,BoolText_A_False
	jsr PrintString
	jsr NewLine
	LDA #False
	rts

Func_B:
	;input: Y = value to check. 0 = false, nonzero = true.
	;output: 0 if false, 255 if true. Also prints the truth value to the screen.
	;USAGE: LDY val JSR Func_B
	TYA
	BEQ .falsehood	;return false
	load16 z_HL,BoolText_B_True
	jsr PrintString
	jsr NewLine
	LDA #True
	rts
.falsehood:
	load16 z_HL,BoolText_B_False
	jsr PrintString
	jsr NewLine
	LDA #False
	rts

Func_A_and_B:
	;input:
	;	z_B = input for Func_A
	;	z_C = input for Func_B
	;output:
		;0 if false, 255 if true
	LDA z_B
	jsr Func_A
	BEQ .falsehood
		LDY z_C
		jsr Func_B
		BEQ .falsehood
			;true
			load16 z_HL,BoolText_A_and_B_True
			jsr PrintString
			jsr NewLine
			LDA #True
			rts
.falsehood:
	load16 z_HL,BoolText_A_and_B_False
	jsr PrintString
	jsr NewLine
	LDA #False
	rts

Func_A_or_B:
	;input:
	;	z_B = input for Func_A
	;	z_C = input for Func_B
	;output:
		;0 if false, 255 if true
	LDA z_B
	jsr Func_A
	BNE .truth
		LDY z_C
		jsr Func_B
		BNE .truth
			;false
			load16 z_HL,BoolText_A_or_B_False
			jsr PrintString
			LDA #False
			rts
.truth:
	load16 z_HL,BoolText_A_or_B_True
	jsr PrintString
	LDA #True
	rts

BoolText_A_True:
	db "A IS TRUE",0
BoolText_A_False:
	db "A IS FALSE",0
BoolText_B_True:
	db "B IS TRUE",0
BoolText_B_False:
	db "B IS FALSE",0

BoolText_A_and_B_True:
	db "A AND B IS TRUE",0
BoolText_A_and_B_False:
	db "A AND B IS FALSE",0
BoolText_A_or_B_True:
	db "A OR B IS TRUE",0
BoolText_A_or_B_False:
	db "A OR B IS FALSE",0


BYTE FUNC a(BYTE x)
  PrintF(" a(%B)",x)
RETURN (x)

BYTE FUNC b(BYTE x)
  PrintF(" b(%B)",x)
RETURN (x)

PROC Main()
  BYTE i,j

  FOR i=0 TO 1
  DO
    FOR j=0 TO 1
    DO
      PrintF("Calculating %B AND %B: call",i,j)
      IF a(i)=1 AND b(j)=1 THEN
      FI
      PutE()
    OD
  OD
  PutE()

  FOR i=0 TO 1
  DO
    FOR j=0 TO 1
    DO
      PrintF("Calculating %B OR %B: call",i,j)
      IF a(i)=1 OR b(j)=1 THEN
      FI
      PutE()
    OD
  OD
RETURN


with Ada.Text_IO;  use Ada.Text_IO;

procedure Test_Short_Circuit is
   function A (Value : Boolean) return Boolean is
   begin
      Put (" A=" & Boolean'Image (Value));
      return Value;
   end A;
   function B (Value : Boolean) return Boolean is
   begin
      Put (" B=" & Boolean'Image (Value));
      return Value;
   end B;
begin
   for I in Boolean'Range loop
      for J in Boolean'Range loop
         Put (" (A and then B)=" & Boolean'Image (A (I) and then B (J)));
         New_Line;
      end loop;
   end loop;
   for I in Boolean'Range loop
      for J in Boolean'Range loop
         Put (" (A or else B)=" & Boolean'Image (A (I) or else B (J)));
         New_Line;
      end loop;
   end loop;
end Test_Short_Circuit;


F sierpinski_carpet(n)
   V carpet = [String(‘#’)]
   L 1..n
      carpet = carpet.map(x -> x‘’x‘’x)
           [+] carpet.map(x -> x‘’x.replace(‘#’, ‘ ’)‘’x)
           [+] carpet.map(x -> x‘’x‘’x)
   R carpet.join("\n")

print(sierpinski_carpet(3))


PRIO ORELSE = 2, ANDTHEN = 3; # user defined operators #
OP ORELSE =  (BOOL a, PROC BOOL b)BOOL: ( a | a | b ),
   ANDTHEN = (BOOL a, PROC BOOL b)BOOL: ( a | b | a );

# user defined Short-circuit_evaluation procedures #
PROC or else =  (BOOL a, PROC BOOL b)BOOL: ( a | a | b ),
     and then = (BOOL a, PROC BOOL b)BOOL: ( a | b | a );

test:(

  PROC a = (BOOL a)BOOL: ( print(("a=",a,", ")); a),
       b = (BOOL b)BOOL: ( print(("b=",b,", ")); b);

CO
# Valid for Algol 68 Rev0: using "user defined" operators #
# Note: here BOOL is being automatically "procedured" to PROC BOOL #
  print(("T ORELSE F = ", a(TRUE) ORELSE b(FALSE), new line));
  print(("F ANDTHEN T = ", a(FALSE) ANDTHEN b(TRUE), new line));

  print(("or else(T, F) = ", or else(a(TRUE), b(FALSE)), new line));
  print(("and then(F, T) = ", and then(a(FALSE), b(TRUE)), new line));
END CO

# Valid for Algol68 Rev1: using "user defined" operators #
# Note: BOOL must be manually "procedured" to PROC BOOL #
  print(("T ORELSE F = ",  a(TRUE) ORELSE  (BOOL:b(FALSE)), new line));
  print(("T ORELSE T = ",  a(TRUE) ORELSE  (BOOL:b(TRUE)), new line));

  print(("F ANDTHEN F = ", a(FALSE) ANDTHEN (BOOL:b(FALSE)), new line));
  print(("F ANDTHEN T = ", a(FALSE) ANDTHEN (BOOL:b(TRUE)), new line));

  print(("F ORELSE F = ",  a(FALSE) ORELSE  (BOOL:b(FALSE)), new line));
  print(("F ORELSE T = ",  a(FALSE) ORELSE  (BOOL:b(TRUE)), new line));

  print(("T ANDTHEN F = ", a(TRUE) ANDTHEN (BOOL:b(FALSE)), new line));
  print(("T ANDTHEN T = ", a(TRUE) ANDTHEN (BOOL:b(TRUE)), new line))

)


BYTE FUNC InCarpet(BYTE x,y)
  DO
    IF x MOD 3=1 AND y MOD 3=1 THEN
      RETURN (0)
    FI
    x==/3 y==/3
  UNTIL x=0 AND y=0
  OD
RETURN (1)

PROC DrawCarpet(INT x0 BYTE y0,depth)
  BYTE i,x,y,size

  size=1
  FOR i=1 TO depth
  DO size==*3 OD

  FOR y=0 TO size-1
  DO
    FOR x=0 TO size-1
    DO
      IF InCarpet(x,y) THEN
        Plot(x0+2*x,y0+2*y)
        Plot(x0+2*x+1,y0+2*y)
        Plot(x0+2*x+1,y0+2*y+1)
        Plot(x0+2*x,y0+2*y+1)
      FI
    OD
  OD
RETURN

PROC Main()
  BYTE CH=$02FC,COLOR1=$02C5,COLOR2=$02C6

  Graphics(8+16)
  Color=1
  COLOR1=$0C
  COLOR2=$02

  DrawCarpet(79,15,4)

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


with Ada.Text_Io; use Ada.Text_Io;

procedure Sierpinski_Carpet is
   subtype Index_Type is Integer range 1..81;
   type Pattern_Array is array(Index_Type range <>, Index_Type range <>) of Boolean;
   Pattern : Pattern_Array(1..81,1..81) := (Others =>(others => true));
   procedure Clear_Center(P : in out Pattern_Array; X1 : Index_Type; X2 : Index_Type;
         Y1 : Index_Type; Y2 : Index_Type) is
      Xfirst : Index_Type;
      Xlast  : Index_Type;
      Yfirst : Index_Type;
      Ylast  : Index_Type;
      Diff   : Integer;
   begin
      Xfirst :=(X2 - X1 + 1) / 3 + X1;
      Diff := Xfirst - X1;
      Xlast  := Xfirst + Diff;
      Yfirst := (Y2 - Y1) / 3 + Y1;
      YLast  := YFirst + Diff;

      for I in XFirst..XLast loop
         for J in YFirst..YLast loop
            P(I, J) := False;
         end loop;
      end loop;
   end Clear_Center;

   procedure Print(P : Pattern_Array) is
   begin
      for I in P'range(1) loop
         for J in P'range(2) loop
            if P(I,J) then
               Put('*');
            else
               Put(' ');
            end if;
         end loop;
         New_Line;
      end loop;
   end Print;

   procedure Divide_Square(P : in out Pattern_Array; Order : Positive) is
      Factor : Natural := 0;
      X1, X2 : Index_Type;
      Y1, Y2  : Index_Type;
      Division : Index_Type;
      Num_Sections : Index_Type;
   begin
      while Factor < Order loop
         Num_Sections := 3**Factor;
         Factor := Factor + 1;
         X1  := P'First;
         Division   := P'Last / Num_Sections;
         X2 := Division;
         Y1 := X1;
         Y2 := X2;
         loop
            loop
               Clear_Center(P, X1, X2, Y1, Y2);
               exit when X2 = P'Last;
               X1 := X2;
               X2 := X2 + Division;
            end loop;
            exit when Y2 = P'Last;
            Y1 := Y2;
            Y2 := Y2 + Division;
            X1 := P'First;
            X2 := Division;
         end loop;
      end loop;
   end Divide_Square;

begin
   Divide_Square(Pattern, 3);
   Print(Pattern);
end Sierpinski_Carpet;


begin

    logical procedure a( logical value v ) ; begin write( "a: ", v ); v end ;
    logical procedure b( logical value v ) ; begin write( "b: ", v ); v end ;

    write( "and: ", a( true  ) and b( true ) );
    write( "---" );
    write( "or:  ", a( true  ) or  b( true ) );
    write( "---" );
    write( "and: ", a( false ) and b( true ) );
    write( "---" );
    write( "or:  ", a( false ) or  b( true ) );
    write( "---" );

end.


on run

    map(test, {|and|, |or|})

end run

-- test :: ((Bool, Bool) -> Bool) -> (Bool, Bool, Bool, Bool)
on test(f)
    map(f, {{true, true}, {true, false}, {false, true}, {false, false}})
end test

-- |and| :: (Bool, Bool) -> Bool
on |and|(tuple)
    set {x, y} to tuple

    a(x) and b(y)
end |and|

-- |or| :: (Bool, Bool) -> Bool
on |or|(tuple)
    set {x, y} to tuple

    a(x) or b(y)
end |or|

-- a :: Bool -> Bool
on a(bool)
    log "a"
    return bool
end a

-- b :: Bool -> Bool
on b(bool)
    log "b"
    return bool
end b

-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
    script mf
        property lambda : f
    end script
    set lng to length of xs
    set lst to {}
    repeat with i from 1 to lng
        set end of lst to mf's lambda(item i of xs, i, xs)
    end repeat
    return lst
end map


PROC in carpet = (INT in x, in y)BOOL: (
    INT x := in x, y := in y;
    BOOL out;
    DO
        IF x = 0 OR y = 0 THEN
            out := TRUE; GO TO stop iteration
        ELIF x MOD 3 = 1 AND y MOD 3 = 1 THEN
            out := FALSE; GO TO stop iteration
        FI;

        x %:= 3;
        y %:= 3
    OD;
    stop iteration: out
);

PROC carpet = (INT n)VOID:
    FOR i TO 3 ** n DO
        FOR j TO 3 ** n DO
            IF in carpet(i-1, j-1) THEN
                print("* ")
            ELSE
                print("  ")
            FI
        OD;
        print(new line)
    OD;

carpet(3)


begin
    for depth := 3 do begin
        integer dim;
        dim   := 1;
        for i := 0 until depth - 1 do dim := dim * 3;
        for i     := 0 until   dim - 1 do begin
            for j := 0 until   dim - 1 do begin
                integer d;
                d := dim div 3;
                while d not = 0
                  and not ( ( i rem ( d * 3 ) ) div d = 1 and ( j rem ( d * 3 ) ) div d = 1 )
                do d := d div 3;
                writeon( if d not = 0 then "  " else "##" )
            end for_j;
            write()
        end for_i;
        write()
    end for_depth
end.


i = 1
j = 1
x := a(i) and b(j)
y := a(i) or b(j)

a(p)
{
 MsgBox, a() was called with the parameter "%p%".
 Return, p
}

b(p)
{
 MsgBox, b() was called with the parameter "%p%".
 Return, p
}


#!/usr/bin/awk -f
BEGIN {
	print (a(1) && b(1))
	print (a(1) || b(1))
	print (a(0) && b(1))
	print (a(0) || b(1))
}

function a(x) {
	print "  x:"x
	return x
}
function b(y) {
	print "  y:"y
	return y
}