in English in Deutsch

433 Examples in 132 (or 162*) programming languages
* including the different dialects

Copyright © 2000, 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
last change: Sunday, 30.11.2003, 18:18:00 by Michael Neumann

If you should find errors on this page or have questions, proposals or further program-examples or languages, you can send me an email to: mneumann@ntecs.de.

Here you can see this page divided into multiple HTML-pages!

Languages: A+, ABAP, ABC, Ada ( Ada 83, Ada 95, Ada 9X(95) ), Aleph, Algae, ALGOL ( ALGOL 60 ), Amos, APL, ASP (Active Server Pages) ( JavaScript, VBScript ), Assembler ( 6502, Apple II (II+, IIe, IIC), IBM Assembler/370 (VM/CMS), Intel 80x86 (DOS, MASM), Intel 80x86 (DOS, TASM), Intel 80x86 (gas/NetBSD), Intel 80x86 (nasm/NetBSD(aout)), Intel 80x86 (nasm), MIDAS PDP-10 (MIT Incompatible Timesharing System), MIPS R2000, Motorola 68000 (ATARI), VAX ), awk, BASIC, BCPL, Befunge, BETA, Blue, Brain, BrainF*ck, C, C#, C++ ( DOS/Windows, DOS/Windows (obsolete C++) ), Cilk, CLAIRE, Clipper, COBOL, Concurrent Clean, Cook, COSY INFINITY, C-Talk, Curl, Cyclone, D, dBASE, DOS Batch, Dylan, E, Eiffel ( SmallEiffel ), Emerald, Erlang, Euphoria, FISh, FOP, Forth ( ANS Forth, ANS Forth, pForth ), Fortran ( Fortran 77, Fortran 90 ), FOX, Gofer, Haskell ( Glasgow Haskell Compiler (GHC) ), HB (Hyper Builder), Hope, HPGL, HTML, IBM EXEC ( IBM EXEC (VM/CMS), IBM EXEC2 (VM/CMS) ), Icon, J, Java, JavaScript, Jovial, K, Labview, LaTeX, Leda, LIRL, Lisp ( Common Lisp, Emacs Lisp ), Logo, Lout, Lua, Make, Mercury, merd, Miranda, Moby, Modula ( Modula-2, Modula-3 ), mpC, MUMPS, NESL, Oberon, Objective-C, Objective Caml, Obliq, Octave, Ook, Oz/Mozart, Parrot, Pascal ( ISO-7185 ), Perl, Phantom, PHP ( PHP3 ), Pico, Pike, PL/0, PL/0E, PL/1, PL/SQL, Pliant, Postscript, Profan, Prolog, Python, R, Ratfor, Rebol, REXX, Ruby, Sather, Scheme, Shell-Sprachen ( csh, es (Extensible Shell), sh,ksh,zsh,bash, sh,ksh,zsh,bash,csh,es, WSH (Windows Scripting Host), zsh ), Simula ( Simula 67 ), Sina, Sirius, Sisal, Smalltalk, SML ( SML/NJ ), SNOBOL ( SNOBOL4 ), SQL ( Oracle SQL ), Superbase, Tcl ( Tcl/Tk ), TI-83 Graphing Calculator, TOM, Turing, TXL, UFO, UML (Unified Modeling Language), VHDL, Vim, WebL, WML (Wireless Markup Language), XPL0, Yacas, YAFL, Yoix, Yorick

Following languages are missing (241, that are in no case all!): 4DOS, 4TH, ABCL/1, ABE, Acore, Act/1, Act/2, Act/3, Actor, Actors, Actra, AeonicScript, Agora, Alfonzo, Algae, ANTLR, Argus, ART, ASP, B, BEAST, Befunge, Berkeley Smalltalk, BISON, Bistro, Blaze, Brouhaha, C mit Klassen, C+-, C-Linda, Caché ObjectScript, Caml, Cantor, Cause, Cayenne, Cecil, CH, Chakotay, Charm, Cid, Clarity, Clascal, Classic Ada, Clay, Clean, Clipper, CLOS, Clu, Cluster 86, ColdC, Common Loops, Common Objects, Common ORBIT, Concurrent Prolog, Concurrent Smalltalk, Coral66, CP, CSSA, CST, cT, Curl, Curry, Delphi, Demeter, Director, Distributed Smalltalk, Dynace, EB, EBL, Eclipse, EcmaScript, Elan, Elegant, Elf, Eli, Elisp (Emacs-Lisp), Escher, Esterel, Expect, ExperCommonLisp, Extended Smalltalk, Felix Pascal, Ficl, FIJI, Flavors, FOOPlog, FOOPS, Forte', Freemarker, FRL, Galileo, Garp, Gentle, GJ (Generic Java), GLISP, Goedel, Guile, Gypsy, HP VEE, HPGL2, Hybrid, ICI, IDL, Inferno, Inheritance, InnovAda, INTERCAL, Intermission, IPL, Jade, Jasmine, Joule, Jovial (Jules' own version of IAL (international algorithmic language)), KL-One, KL1, KRL, KRS, Lagoona, Laure, Lens, LEX, LIFE, Limbo, Linda, Little Smalltalk, LL, LOOPS, Lore, LPC (Lars Pensjö C), Lua, Lucid, Lyric, Mace, MACSYMA, MALAGA, Maple, Mathematica, Mawl, MELD, Mercury, MetaHTML, Mjolner, ModPascal, MOM, Morphe, mpC, Mutt, Napier88, Neon, New Flavors, NIL, O-CPU, OakLisp, Object Assembler, Object Cobol, Object Lisp, Object Logo, Object Oberon, Object Pascal, ObjVLisp, Occam, Omega, OmniMark, OOPC, OOPS+, OPAL, OPL, Orbit, Orca, Orient84/K, OTM, PaL, Parsec, pC++ Sage++, PCOL, PF, PIE, Pilot, Pizza, PL/LL, PLAN, Plankalkül, Plasma II, POOL-T, Pop-11, PROCOL, Prometheus, PROMOTER, Quick Pascal, Quicktalk, Rebus, RIGAL, ROIS NPL, ROSS, S3L, SAL, SAST, SCOOP, SCOOPS, Scotty, sed, Self, SGML, Simscript, Smalltalk AT, Smalltalk V, Smallworld, SOUL (Smalltalk Open Unification Language), Spanner, SPOOL, SR, SRL, STROBE, T, T-Cham, Tempo, Tex, Theta, Tipi, Transframe, Trellis/Owl, Turing, TXL, Tycoon, µLPC, Uniform, UNITS, V, VBScript, VHDL, VIRT, Vulcan, WebMacro, WML (Website Meta Language), XLISP, XML, XSL, YACC, Yodl, Z, Zoom/VM ...

ChangeLog

| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | R | S | T | U | V | W | X | Y |



A+  
    Hello World    19.09.2001
    Squares    19.09.2001
    Squares 2-dimensional    19.09.2001

ABAP  
    Hello World    19.07.2002

ABC  
    Hello World
    Squares

Ada  
    Hello World    Ada 83
    Hello World    Ada 95
    OO - Shape, Circle, Rectangle    Ada 95    10.06.2002
    Squares    Ada 9X(95)    23.06.2000

Aleph   functional
    Factorial    09.07.2000
    Hello World    09.07.2000
    Squares    09.07.2000

Algae  
    Hello World    05.12.2002
    Misc    16.05.2003
    Squares (1)    05.12.2002
    Squares (2)    05.12.2002

ALGOL  
    Hello World (1)    ALGOL 60
    Hello World (2)    ALGOL 60
    Squares    ALGOL 60

Amos  
    Hello World

APL  
    Hello World
    Squares
    Squares 2-dimensional

ASP (Active Server Pages)  
    Hello World    JavaScript    17.12.2000
    Hello World    VBScript    17.12.2000

Assembler  
    Hello World    6502, Apple II (II+, IIe, IIC)    29.11.2001
    Hello World    IBM Assembler/370 (VM/CMS)    17.12.2000
    Squares    IBM Assembler/370 (VM/CMS)    10.01.2000
    Hello World    Intel 80x86 (DOS, MASM)    30.12.2001
    Hello World    Intel 80x86 (DOS, TASM)
    Hello World    Intel 80x86 (gas/NetBSD)    25.09.2000
    Hello World    Intel 80x86 (nasm/NetBSD(aout))    25.09.2000
    Fast and Good Hash Function    Intel 80x86 (nasm)    20.06.2002
    Hello World    MIDAS PDP-10 (MIT Incompatible Timesharing System)    30.12.2001
    Squares    MIDAS PDP-10 (MIT Incompatible Timesharing System)    30.12.2001
    Hello World    MIPS R2000    01.05.2002
    Hello World    Motorola 68000 (ATARI)
    Hello World    VAX    30.12.2001

awk  
    Hello World    09.09.2000
    Squares    09.09.2000

BASIC  
    Hello World
    Squares

BCPL  
    Hello World    30.12.2001

Befunge  
    Squares (1)    06.05.2001
    Squares (2)    07.05.2001

BETA  
    Hello World
    Loop-Test
    Squares

Blue  
    Hello World    24.06.2000

Brain  
    Factorial    25.04.2001
    Hello World    25.04.2001
    Squares    25.04.2001

BrainF*ck  
    Hello World    31.12.2001
    Squares    03.11.2001

C  
    Calculate PI    03.12.2002
    Hello World
    Multi-Threaded (forking) Echo-Server    09.01.2002
    Single-Threaded (non-forking) Echo-Server    09.01.2002

C#  
    Hello World    28.06.2000
    Squares (1)    28.06.2000
    Squares (2)    28.06.2000

C++  
    Boyer-Moore Search    20.07.2001
    BubbleSort    20.07.2001
    BucketSort    20.07.2001
    gcd    20.07.2001
    Hash1    20.07.2001
    hashpjw    20.07.2001
    Hello World (1)    25.04.2001
    Hello World (2)    25.04.2001
    Hello World (standard)    28.09.2003
    InsertionSort    20.07.2001
    MergeSort    20.07.2001
    QuickSort    20.07.2001
    SelectionSort    20.07.2001
    ShellSort    20.07.2001
    Hello World (1)    DOS/Windows
    Hello World (2)    DOS/Windows (obsolete C++)

Cilk  
    Hello World
    Squares

CLAIRE  
    Hello World
    Squares

Clipper  
    Hello World    09.09.2000
    Squares    30.11.2003

COBOL  
    Hello World

Concurrent Clean   functional
    Ackermann    15.04.2002
    Array Access    15.04.2002
    Factorial    15.04.2002
    Fibonacci    15.04.2002
    Hello World
    Hello World    29.05.2003
    Squares
    String Concatenation    15.04.2002

Cook  
    Hello World    01.01.2002
    Squares    01.01.2002

COSY INFINITY  
    Hello World    25.06.2000

C-Talk  
    Eulersche Number (1)    25.06.2000
    Eulersche Number (2)    25.06.2000
    Factorial    25.06.2000
    Hello World    25.06.2000
    Squares    25.06.2000

Curl  
    Hello World    29.11.2001

Cyclone  
    Hello World    05.07.2003

D  

dBASE  
    Hello World    09.09.2000

DOS Batch  
    Hello World
    Numbers

Dylan   functional
    Hello World
    OO - Shape, Circle, Rectangle    30.05.2002
    Squares

E   functional
    Hello World    24.06.2000
    Squares

Eiffel  
    Hello World
    Hello World    SmallEiffel    31.10.2001

Emerald  
    Hello World
    Squares

Erlang   functional
    Hello World
    Squares

Euphoria  
    Discouragement example     19.10.2000
    Hello World
    Squares

FISh   functional
    Hello World    19.03.2001
    Squares (1)    19.03.2001
    Squares (2)    19.03.2001

FOP  
    Hello World    01.05.2002

Forth  
    CGI Squares    23.09.2001
    Discouragement example
    Hello World (1)
    Hello World (2)
    Loop-Test
    Squares    19.09.2001
    Absolute value    ANS Forth    04.09.2003
    Factorial    ANS Forth    20.09.2001
    Factorial    ANS Forth, pForth    20.9.2001

Fortran  
    Hello World    Fortran 77    08.10.2000
    Squares    Fortran 77    08.10.2000
    Hello World    Fortran 90
    Matrix Multiplication    Fortran 90    02.06.2003

FOX  
    Hello World    09.09.2000

Gofer   functional
    Ackermann    30.10.2001
    ADT Stack    30.10.2001
    Factorial    13.10.2000
    gcd    30.10.2001
    Hello World    13.10.2000
    Length of a list    30.10.2001
    MergeSort    30.10.2001

Haskell   functional
    Factorial (1)    03.08.2001
    Factorial (2)    03.08.2001
    Fibonacci    31.12.2001
    HaXml Demo Application    18.10.2001
    Hello World
    InsertionSort    04.07.2003
    InsertionSort (2)    04.07.2003
    Quicksort
    Squares (1)
    Squares (2)
    Squares (3)    16.10.2001
    Squares (4)    31.12.2001
    Hello World    Glasgow Haskell Compiler (GHC)    23.02.2003

HB (Hyper Builder)  
    Hello World    04.07.2000
    Simple HTML-form    04.07.2000

Hope   functional
    Hello World
    Squares

HPGL  
    Hello World    22.07.2002

HTML  
    Hello World

IBM EXEC  
    Hello World    IBM EXEC (VM/CMS)    17.12.2000
    Hello World    IBM EXEC2 (VM/CMS)    17.12.2000

Icon  
    Hello World
    Squares

J  
    Eulersche Number (1)
    Eulersche Number (2)    09.11.2001
    Hello World
    Squares (1)
    Squares (2)    23.02.2001

Java  
    Hello World (Applet)
    Hello World (Application)
    Hello World (Servlet)    11.10.2000
    Hello World (Swing-GUI)    23.09.2001
    Multi-threading    30.12.2001

JavaScript  
    Hello World (1)
    Hello World (2)    02.12.2001
    Squares    02.12.2001

Jovial  

K  
    Eulersche Number    24.06.2000
    Factorial (iterative)    24.06.2000
    Factorial (recursive)    24.06.2000
    Hello World    24.06.2000
    Squares (1)    24.06.2000
    Squares (2)    24.06.2000

Labview  
    Complex Example    28.11.2002

LaTeX  
    Factorial    31.12.2001
    Fibonacci    31.12.2001
    Hello World    24.09.2000
    Squares    31.12.2001

Leda  
    Hello World
    Squares

LIRL   functional
    Factorial    01.05.2002
    Fibonacci Sequence    01.05.2002
    Hello World    01.05.2002

Lisp   functional
    Hello World
    Factorial (iterative)    Common Lisp    19.04.2002
    Factorial (recursive)    Common Lisp    19.04.2002
    Hello World    Common Lisp    19.04.2002
    OO - Shape, Circle, Rectangle    Common Lisp    19.04.2002
    Squares (1)    Common Lisp    17.11.2001
    Squares (2)    Common Lisp    19.04.2002
    Squares (3)    Common Lisp    19.04.2002
    Squares    Emacs Lisp

Logo  
    Hello World

Lout  
    Hello World    25.09.2000

Lua  
    Factorial    23.09.2001
    Hello World    23.09.2001
    Squares (1)    23.09.2001
    Squares (2)    23.09.2001

Make  
    Hello World    09.09.2000
    Squares    09.09.2000

Mercury  
    Factorial    29.05.2003
    Hello World    29.05.2003
    Length of a list    29.05.2003

merd   functional
    Factorial    22.10.2001
    Hello World    22.10.2001
    Squares (1)    22.10.2001
    Squares (2)    22.10.2001

Miranda   functional
    Factorial (1)    30.10.2001
    Factorial (2)    30.10.2001
    gcd    29.10.2001
    Hello World    29.10.2001
    Quicksort    29.10.2001
    Squares (1)    29.10.2001
    Squares (2)    29.10.2001

Moby   functional
    Hello World    14.06.2003

Modula  
    Hello World    Modula-2
    Hello World    Modula-3
    Squares    Modula-3

mpC  

MUMPS  
    Hello World (1)    30.03.2001
    Hello World (2)    30.03.2001
    Hello World (interpreted mode)    30.03.2001
    Sorting    30.03.2001
    Squares (1)    30.03.2001
    Squares (2)    30.03.2001
    Squares (interpreted mode)    30.03.2001

NESL   functional
    Hello World
    Squares

Oberon  
    Hello World

Objective-C  
    Hello World (1)
    Hello World (2)
    Squares

Objective Caml   functional
    Factorial (1)    03.03.2001
    Factorial (2)    03.03.2001
    gcd    03.03.2001
    Hello World    13.01.2001
    InsertionSort    04.07.2003
    Length of a list    03.03.2001
    Squares (functional)    13.01.2001
    Squares (imperative)    03.03.2001
    Squares (recursive)    13.01.2001
    XML-RPC parser    26.07.2001

Obliq  
    Hello World
    Squares

Octave  
    Hello World    24.06.2000
    Squares    1.10.2000

Ook  
    Squares    03.11.2001

Oz/Mozart   functional
    Factorial (1)    25.04.2001
    Factorial (2)    25.04.2001
    Factorial (3)    25.04.2001
    Factorial (4)    25.04.2001
    Hello World
    Hello World (2)    29.11.2002
    Squares (1)
    Squares (2)    26.02.2001

Parrot  
    Hello World    02.11.2001
    Squares    02.11.2001

Pascal  
    Hello World
    Hello World    ISO-7185    28.09.2003

Perl  
    Factorial (1)    23.09.2001
    Factorial (2)    12.11.2001
    Hello World
    References    23.09.2001
    Squares (1)
    Squares (2)    23.09.2001
    Squares (3)    21.10.2001
    Squares (4)    09.11.2001
    Substitution

Phantom  
    Hello World
    Squares

PHP  
    Hello World    PHP3
    Squares    PHP3

Pico   functional
    Eulersche Number    26.06.2000
    Factorial    26.06.2000
    Hello World    26.06.2000
    Squares (1)    26.06.2000
    Squares (2)    26.06.2000

Pike  
    Factorial    25.06.2000
    Hello World    25.06.2000
    Squares (1)    25.06.2000
    Squares (2)    25.06.2000

PL/0  
    Hello World    25.06.2000
    Squares    25.06.2000

PL/0E  
    Hello World
    Squares

PL/1  
    Hello World    17.12.2000
    Squares    10.01.2001

PL/SQL  
    Hello World    07.10.2000
    Squares    07.10.2000

Pliant   functional
    Factorial    26.06.2000
    Hello World    26.06.2000
    Squares    26.06.2000

Postscript  
    Hello World

Profan  
    Hello World
    Squares

Prolog  
    Factorial
    Finite Domain Constraint Programming    11.04.2003
    Hello World

Python  
    gcd    20.07.2001
    Hello World
    OO - Shape, Circle, Rectangle    01.11.2001
    QuickSort    20.07.2001
    Squares (1)
    Squares (2)

R  
    Hello World    03.11.2000
    Squares (1)    03.11.2000
    Squares (2)    03.11.2000

Ratfor  
    Hello World    30.12.2001

Rebol  
    Factorial (1)    17.11.2000
    Factorial (2)    17.11.2000
    Hello World
    Squares (1)
    Squares (2)
    Squares (3)    17.11.2000

REXX  
    Hello World
    Quicksort    14.05.2001
    Squares (1)
    Squares (2)

Ruby  
    Binary Search Tree    30.09.2001
    Calculate PI    20.07.2001
    Calculate PI    25.11.2003
    Factorial    08.10.2000
    Factorial (2)    13.11.2001
    Factorial (tail-recursive)    25.09.2001
    gcd    20.07.2001
    Hash1 - Standard hash-function    19.05.1999
    hashpjw    20.07.2001
    Heapsort    06.10.2001
    Hello World (1)
    Hello World (2)    25.10.2001
    OO - Shape, Circle, Rectangle    01.11.2001
    Quicksort    19.05.1999
    RC4    25.07.2001
    Sieve of Eratosthenes    16.10.2001
    Squares (1)
    Squares (2)
    Squares (3)    09.08.2000
    Squares (4)    09.10.2001

Sather  
    Factorial    03.09.2001
    Hello World
    Squares (1)    03.09.2001
    Squares (2)    03.09.2001
    Squares (3)    03.09.2001

Scheme   functional
    Factorial    05.11.2000
    Hello World (1)    05.11.2000
    Hello World (2)    01.03.2001
    Squares (1)    05.11.2000
    Squares (2)    01.03.2001

Shell-Sprachen  
    Squares    csh    24.09.2000
    Squares    es (Extensible Shell)    26.09.2000
    Factorial    sh,ksh,zsh,bash    24.06.2000
    Squares    sh,ksh,zsh,bash    24.06.2000
    Hello World    sh,ksh,zsh,bash,csh,es    24.06.2000
    Hello World    WSH (Windows Scripting Host)    29.11.2001
    Bookmark Script    zsh    20.07.2001

Simula  
    Hello World    Simula 67
    Squares    Simula 67

Sina  
    Hello World

Sirius  
    Hello World
    Squares

Sisal   functional
    Hello World
    Squares

Smalltalk  
    Hello World
    Quicksort
    Squares (1)
    Squares (2)    06.08.2000

SML   functional
    Hello World
    Squares (1)
    Squares (2)
    Word Tokenizer    20.06.2002
    Hello World    SML/NJ    17.06.2002

SNOBOL  
    Factorial    SNOBOL4    26.06.2000
    Hello World    SNOBOL4    26.06.2000
    Squares    SNOBOL4    26.06.2000

SQL  
    Hello World
    Hello World    Oracle SQL    4.10.2000

Superbase  
    Hello World    07.01.2002

Tcl  
    Hello World
    Squares
    Substitution
    Hello World    Tcl/Tk

TI-83 Graphing Calculator  
    Eulersche Number    07.01.2002
    Hello World    07.01.2002
    Squares    07.01.2002

TOM  
    Hello World
    Squares

Turing  
    Factorial    07.05.2001
    Hello World    07.05.2001
    Squares    07.05.2001

TXL   functional
    Bubblesort    07.05.2001
    Hello World    07.05.2001
    Squares    07.05.2001

UFO   functional
    Hello World
    Squares

UML (Unified Modeling Language)  
    OO - Shape, Circle, Rectangle (1)    01.11.2001
    OO - Shape, Circle, Rectangle (2)    01.11.2001

VHDL  
    Hello World    07.01.2002

Vim  
    Hello World    24.09.2000
    Squares    24.09.2000

WebL  
    Factorial    24.06.2000
    Hello World    24.06.2000
    Squares (1)    24.06.2000
    Squares (2)    24.06.2000

WML (Wireless Markup Language)  
    Hello World

XPL0  
    Hello World    12.05.2001
    Squares    12.05.2001

Yacas  
    Factorial (1)    26.09.2000
    Factorial (2)    26.09.2000
    Hello World    26.09.2000

YAFL  
    Hello World    30.06.2000

Yoix  
    Factorial    04.09.2001
    Hello World (1)    04.09.2001
    Hello World (2)    04.09.2001
    Squares (1)    04.09.2001
    Squares (2)    04.09.2001

Yorick  
    Eulersche Number    27.06.2000
    Factorial    27.06.2000
    Hello World    27.06.2000
    Squares (1)    27.06.2000
    Squares (2)    27.06.2000






 A+    up http://www.aplusdev.org
  similar languages: APL   J   K  
  Description: A+ is an APL-like languge. It's released under the GNU GPL license. Important Note: APL's vectors start with 1 where in A+ this is 0.


 Hello World   Michael Neumann

Prints "Hello World" onto the screen.


 Squares   Michael Neumann

Outputs the squares from 1 to 10.


 Squares 2-dimensional   Michael Neumann

Ouputs the squares from 1 to 9 as a 2-dimensional array:
 1  4  9
16 25 36
49 64 81







 ABAP    up
 
  Description: Programming language by SAP (large german IT company).


 Hello World   Knut Lickert
Report Hello_World.
Write: "Hello World".
Prints "Hello World" onto the screen.






 ABC    up
  similar languages: Amos   BASIC   Euphoria   Profan   REXX  
 


 Hello World   Michael Neumann
WRITE "Hello World"
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
FOR i IN {1..10}
   WRITE i*i
Outputs the squares from 1 to 10.






 Ada    up
  similar languages: ALGOL   Simula  
 


 Hello World   Ada 83   Michael Neumann
-- Hello World
with Text_IO;
use Text_IO;

procedure HelloWorld is
begin
   Put_Line("Hello World");
end HelloWorld;
Prints "Hello World" onto the screen.


 Hello World   Ada 95   Michael Neumann
-- Hello World
with Ada.Text_IO;
use Ada.Text_IO;

procedure HelloWorld is
begin
   Put_Line("Hello World");
end HelloWorld;
Prints "Hello World" onto the screen.


 OO - Shape, Circle, Rectangle   Ada 95   Michael Neumann
-- File:   oo.ads
-- Author: Michael Neumann

package OO is

   type Byte is range 0 .. 255;
   for Byte'Size use 8;

   type Color is
      record
         Red,
         Green,
         Blue  : Byte;
      end record;

   type Shape is abstract tagged
      record
         X,
         Y : Integer;
         C : Color;
      end record;

   type Circle is new Shape with
      record
         Radius : Integer;
      end record;

   type Rectangle is new Shape with
      record
         Width,
         Height : Integer;
      end record;

   procedure Move (
         Self : in out Shape'Class;
         DX,
         DY    :        Integer      );

   procedure Draw (
         Self : in     Circle'Class );


   procedure Draw (
         Self : in     Rectangle'Class );

   function Get_Area (
         Self : in     Circle'Class )
     return Integer;


   function Get_Area (
         Self : in     Rectangle'Class )
     return Integer;

end OO;
-- File:   oo.adb
-- Author: Michael Neumann

package body OO is

   procedure Move (
         Self : in out Shape'Class;
         DX,
         DY   :        Integer      ) is
   begin
      Self.X := Self.X + DX;
      Self.Y := Self.Y + DY;
   end Move;

   procedure Draw (
         Self : in     Circle'Class ) is
   begin
      -- Do something here      
      null;
   end Draw;

   procedure Draw (
         Self : in     Rectangle'Class ) is
   begin
      -- Do something here
      null;
   end Draw;


   function Get_Area (
         Self : in     Circle'Class )
     return Integer is
      Pi : constant Float := 3.1415;
   begin
      return Integer( Pi * Float(Self.Radius) );
   end;

   function Get_Area (
         Self : in     Rectangle'Class )
     return Integer is
   begin
      return Self.Width * Self.Height;
   end;

end OO;
-- File:   oo_test.adb
-- Author: Michael Neumann

with Ada.Text_IO, OO;
use Ada.Text_IO, OO;

procedure OO_Test is
   package MyInt is new Integer_IO(Integer);
   use MyInt;

   BLACK : constant Color := (0, 0, 0);
   WHITE : constant Color := (255, 255, 255);

   Circ : Circle;
   Rect : Rectangle;
begin

   Circ := Circle'(
      X      => 100,
      Y      => 100,
      Radius => 50,
      C      => BLACK);

   Rect := Rectangle'(
      X      => 20,
      Y      => 20,
      Width  => 5,
      Height => 5,
      C      => WHITE);

   Move(Circ, DY => 10, DX => 10);
   Circ.X := 50;
   Circ.Radius := 5;

   Put( Get_Area(Circ) ); -- => 16 (Ada always rounds numbers up)
   Put( Get_Area(Rect) ); -- => 25

   Put( Rect.Width ); -- => 5
   Rect.Width := 10;
   Put( Rect.Width ); -- => 10

   Draw(Circ);
   Draw(Rect);
end;



 Squares   Ada 9X(95)   Michael Neumann
with Ada.Text_IO; 

procedure Squares is
use Ada.Text_IO;
package MyInt is new Integer_IO(Integer);
begin
   for I in 1..10 loop
      MyInt.Put(I*I);
      Put(" ");
   end loop;
   New_Line;
end Squares;
Outputs the squares from 1 to 10.






 Aleph    up http://www.aleph-lang.org
 
  Description: Aleph is an interpreted, object-oriented, functional language which inherits many from Scheme and C++.


 Factorial   Michael Neumann
trans fac (n) (
   if (> n 1) (* n (fac (- n 1))) 1
)

println (fac 6)
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
# Hello World in Aleph

println "Hello World"
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
# deklariere Variable
trans index 1

while (< index 11) {
   println (* index index) " "
}
Outputs the squares from 1 to 10.






 Algae    up http://algae.sourceforge.net
 
  Description: Algae is an interpreted language for numerical analysis and matrix processing, similar to Octave or MATLAB. Algae is said to be very fast. It is free software under the GNU General Public License.

Some facts:

  • dynamically typed, interpreted
  • exceptions
  • functions are first-class
  • types: scalars, vectors, matrices, tables(records)
  • C-ish syntax


 Hello World   Michael Neumann
# Hello World in Algae

printf("Hello World\n");
Prints "Hello World" onto the screen.


 Misc   Michael Neumann
# fill(shape; values)
fill(3,4; 1,2,3,4)   # => 3x4 matrix filled (row-wise) with 1,2,3,4

diag(1,2,3) # 3x3 matix with 1,2,3 on the diagonal

# linspace(a; b; n)
linspace(1;10;100)  creates a vector with 100 elements from 1 to 10

# ident(n)
# creates the nxn identity matrix



 Squares (1)   Michael Neumann
# Note that functions can be applied to scalars as well as to vectors or matrices
squares = function(x)
{
  return x^2;
}

nums = 1:10:1;    # a vector containing elements from 1 to 10

print( squares(nums) );
# or ...
print( nums^2 );
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
for (i in 1:10) {
  printf("%d "; i^2);
}
printf("\n");
Outputs the squares from 1 to 10.






 ALGOL    up
  similar languages: Ada   Simula  
 


 Hello World (1)   ALGOL 60   Michael Neumann
'begin'
   outstring(2, 'Hello World');
'end'
Prints "Hello World" onto the screen.


 Hello World (2)   ALGOL 60   Michael Neumann
'begin'
   'string'  s := 'Hello World';
   'integer' i;

   'for' i := 1 'step' 1 'until' length(s) 'do' outsymbol(2,s,i);
'end'
Prints "Hello World" onto the screen.


 Squares   ALGOL 60   Michael Neumann
'begin' 'comment' gibt die Quadrate von 1 bis 10 aus;
   'integer' i;

   'for' i := 1 'step' 1 'until' 10 'do'
   'begin'
      outinteger(2,i*i);
   'end' --for-----diese Schleife gibt die Quadrate aus
'end' --Ende des Programmes
Outputs the squares from 1 to 10.






 Amos    up
  similar languages: ABC   BASIC   Euphoria   Profan   REXX  
 


 Hello World   Michael Neumann
PRINT "Hello World"
Prints "Hello World" onto the screen.






 APL    up
  similar languages: A+   J   K  
  Description: APL (A Programming Language) is a vector based language, that is a language that works likely with vectors or matrices. It was developed by IBM.


 Hello World   Michael Neumann

Prints "Hello World" onto the screen.


 Squares   Michael Neumann

Outputs the squares from 1 to 10.


 Squares 2-dimensional   Michael Neumann

Ouputs the squares from 1 to 9 as a 2-dimensional array:
 1  4  9
16 25 36
49 64 81







 ASP (Active Server Pages)    up
 
 


 Hello World   JavaScript   B. Bora Bali
<%@ language="javascript" %>
<html><body>
<%
  Response.Write('Hello World!');
%>
</body></html>

Prints "Hello World" onto the screen.


 Hello World   VBScript   B. Bora Bali
<%@ language="vbscript" %>
<html><body>
<%
  Response.write "Hello World!"
%>
</body></html>

Prints "Hello World" onto the screen.






 Assembler    up
 
 


 Hello World   6502, Apple II (II+, IIe, IIC)   Steve Hawley
; Uses S-C Assembler variant.
; .or is origin
; .as is ASCII String
; .hs is Hex String
        .or $300
main    ldy #$00
.1      lda str,y
        beq .2
        jsr $fded ; ROM routine, COUT, y is preserved
        iny
        bne .1
.2      rts
str     .as "HELLO WORLD"
        .hs 0D00
Prints "Hello World" onto the screen.


 Hello World   IBM Assembler/370 (VM/CMS)   B. Bora Bali
TITLE 'Hello World for IBM Assembler/370 (VM/CMS)'
HELLO    START
         BALR  12,0
         USING *,12
*
         WRTERM 'Hello World!'
*
         SR    15,15
         BR    14
*
END   HELLO
Prints "Hello World" onto the screen.


 Squares   IBM Assembler/370 (VM/CMS)   B. Bora Bali
         TITLE 'Squares from 1 to 10 - IBM Assembler/370 (VM/CMS)'
*
SQUARE   START
         BALR  12,0
         USING *,12
*
         LA    4,1                * Start value = 1
         LR    2,4                * Increment by 1
         LA    3,10               * Range value = 10
*
LOOP     EQU   *
         LR    7,4                * Copy the loop value
         MR    6,7                * Multiply by itself
*
         CVD   7,DW               * Convert it to decimal
         MVC   WORKAREA,PATTERN   * Copy edit pattern
         EDMK  WORKAREA,DW        * Convert decimal value to character
         WRTERM WORKAREA,16       * Display
*
         BXLE  4,2,LOOP           * Iterate until R4 <= R3
*
         SR    15,15
         BR    14
*
DW       DS    D
WORKAREA DS    XL16
PATTERN  DC    X'40202020202020202020202020202120'
*
         END   SQUARE
Outputs the squares from 1 to 10.


 Hello World   Intel 80x86 (DOS, MASM)   Brad Coomer
.MODEL tiny
.CODE
        ORG 100h
HELLO          PROC
        MOV     AH,09h
        LEA     DX,msg
        INT     21h                     ;Display Hello World

        MOV     AX,4C00h                ;Exit to DOS
        INT     21h
HELLO          ENDP
        msg     DB      'Hello World$'
        END     HELLO
Prints "Hello World" onto the screen.


 Hello World   Intel 80x86 (DOS, TASM)   Michael Neumann
; WRITTEN IN TASM (Turbo Assembler)
.MODEL TINY
CODE SEGMENT
ASSUME CS:CODE, DS:CODE
ORG 100h
START:
        mov ah,9
        mov dx,OFFSET Msg
        int 21h
        int 20h
        Msg DB 'Hello World',13,10,'$'
CODE ENDS
END START 
Prints "Hello World" onto the screen.


 Hello World   Intel 80x86 (gas/NetBSD)   Michael Neumann
/*
 *  Hello World in gas/NetBSD
 *  AT/T-Syntax
 *
 *  Compile:
 *    gas hw.s 
 *    ld -s -o hw a.out
 */

.data

msg:
    .string "Hello World\n"
  
len: 
    .long . - msg


.text
.globl _start

_start:
    push $len        /* Laenge */
    push $msg        /* Adresse */
    push $1          /* Stdout */
    movl $0x4, %eax  /* write */
    call _syscall
    addl $12, %esp   /* Stack bereinigen */

    push $0
    movl $0x1, %eax  /* exit */
    call _syscall
  
_syscall:
    int  $0x80
    ret

Prints "Hello World" onto the screen.


 Hello World   Intel 80x86 (nasm/NetBSD(aout))   Michael Neumann
;
; Hello World in nasm/NetBSD(aout)
;

; Compile:
;    nasm -f aoutb hw.asm
;    ld -s -o hw hw.o

section .text


_start:
    push    dword len    ; Länge
    push    dword msg    ; Adresse
    push    dword 1      ; Stdout
    mov     eax, 0x4     ; write
    call    _syscall
    add     esp, 12      ; Stack bereinigen

    push    dword 0
    mov     eax, 0x1     ; exit
    call    _syscall

_syscall:
    int     0x80
    ret

msg db      "Hello World",0xa
len equ     $ - msg

Prints "Hello World" onto the screen.


 Fast and Good Hash Function   Intel 80x86 (nasm)   Michael Neumann
;;
;; A Fast and Good Hash Function
;;
;; Algorithm by Bob Jenkins, December 1996
;; (see http://burtleburtle.net/bob/c/lookupa.c for C version)
;;
;; Implemented by Michael Neumann, June 2002.
;;
;; Requires NASM - the Netwide Assembler.
;;

global s_lookup
section .text

%macro mix_line 6
        ;;; parameters: r x y shift temp direction(left|right)
        ;;; r -= x; r -= y; r ^= (y(>>|<<)shift)

        ; r -= x
        sub %1, %2

        ; r -= y
        sub %1, %3

        ; r ^= (y>>shift)
        mov %5, %3
%ifidni %6,left
        shl %5, %4
%else
        shr %5, %4
%endif
        xor %1, %5
%endmacro

%macro mix 4
        ;;; parameters: a b c temp

        ;;;a -= b; a -= c; a ^= (c>>13); 
        mix_line %1, %2, %3, 13, %4, right

        ;;;b -= c; b -= a; b ^= (a<<8); 
        mix_line %2, %3, %1, 8, %4, left

        ;;;c -= a; c -= b; c ^= (b>>13); 
        mix_line %3, %1, %2, 13, %4, right

        ;;;a -= b; a -= c; a ^= (c>>12);  
        mix_line %1, %2, %3, 12, %4, right

        ;;;b -= c; b -= a; b ^= (a<<16); 
        mix_line %2, %3, %1, 16, %4, left

        ;;;c -= a; c -= b; c ^= (b>>5); 
        mix_line %3, %1, %2, 5, %4, right

        ;;;a -= b; a -= c; a ^= (c>>3);  
        mix_line %1, %2, %3, 3, %4, right

        ;;;b -= c; b -= a; b ^= (a<<10); 
        mix_line %2, %3, %1, 10, %4, left

        ;;;c -= a; c -= b; c ^= (b>>15); 
        mix_line %3, %1, %2, 15, %4, right
%endmacro

jump_table: dd case0, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11

; unsigned long s_lookup(void *key, int length, int level)
s_lookup:

%define temp edx        ; temporary register: edx
%define a ecx           ; a 
%define b ebx           ; b
%define c eax           ; c
%define len edi         ; len
%define key esi         ; key

        push    ebp
        mov     ebp, esp
        push    esi
        push    edi
        push    ebx
        push    ecx
        push    edx
        ; --------------------------------------------------------

        mov     key, [ebp+8]            ; first argument (key)

        ; Set up the internal state

        ;;; len = length
        mov     len, [ebp+12]           ; second argument (length)

        ;;; a = b = 0x9e3779b9 
        mov     a, 9e3779b9h
        mov     b, a

        ;;; c = level
        mov     c, [ebp+16]

        ;;; while (len >= 12)
while:
        cmp len, 12
        jl near end_while                  ; exit if len < 12

        ;;; a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24));
        add a, [key]

        ;;; b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24));
        add b, [key+4]

        ;;; c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24));
        add c, [key+8]

        mix a, b, c, temp

        add key, 12
        sub len, 12

        jmp near while

end_while:

        ;;; c += length;
        add c, [ebp+12]


;; jump table

        jmp [jump_table+len*4]

case11:
        add a, [key]       ; cases 1,2,3,4
        add b, [key+4]     ; cases 5,6,7,8
        mov temp, [key+8]  ; cases 9,10,11
        shl temp, 8
        add c, temp
        jmp ende

case10:
        add a, [key]       ; cases 1,2,3,4
        add b, [key+4]     ; cases 5,6,7,8
        mov temp, [key+8]  ; cases 9,10
        shl temp, 8
        and temp, 0FFFFFFh
        add c, temp
        jmp ende

case9:
        add a, [key]       ; cases 1,2,3,4
        add b, [key+4]     ; cases 5,6,7,8
        mov temp, [key+8]  ; cases 9
        shl temp, 8
        and temp, 0FFFFh
        add c, temp
        jmp ende

case8:
        add a, [key]     ; cases 1,2,3,4
        add b, [key+4]   ; cases 5,6,7,8
        jmp ende

case7:
        add a, [key]       ; cases 1,2,3,4
        mov temp, [key+4]  ; cases 5,6,7
        and temp, 0FFFFFFh
        add b, temp
        jmp ende

case6:
        add a, [key]       ; cases 1,2,3,4
        mov temp, [key+4]  ; cases 5,6
        and temp, 0FFFFh
        add b, temp
        jmp ende

case5:
        add a, [key]       ; cases 1,2,3,4
        mov temp, [key+4]  ; cases 5
        and temp, 0FFh
        add b, temp
        jmp ende

case3:
        mov temp, [key]
        and temp, 0FFFFFFh
        add a, temp        ; cases 1,2,3
        jmp ende

case2:
        mov temp, [key]
        and temp, 0FFFFh
        add a, temp        ; cases 1,2
        jmp ende

case1:
        mov temp, [key]
        and temp, 0FFh
        add a, temp        ; cases 1
        jmp ende

;; the last case should be the most often occuring one (so we can save one jump instruction)
case4:
        add a, [key]       ; cases 1,2,3,4

case0:
ende:

        mix a, b, c, temp


        ; return value in eax
%ifnidni c,eax
        mov eax, c
%endif

        ; --------------------------------------------------------
        pop     edx
        pop     ecx
        pop     ebx
        pop     edi
        pop     esi
        pop     ebp
        ret
Generates 32-bit hash values from a given string.


 Hello World   MIDAS PDP-10 (MIT Incompatible Timesharing System)   Rob Austein
;; Hello world in MIDAS

title   hello

start:  .open   [.uao,,'tty ? 0 ? 0]
         .lose  %lsfil
        move    1, [440700,,[asciz "Hello, world
"]]
loop:   ildb    2,1
        skipn   2
         .logou 1,
        .iot    2
        jrst    loop

end     start
Prints "Hello World" onto the screen.


 Squares   MIDAS PDP-10 (MIT Incompatible Timesharing System)   Rob Austein
;; Squares of integers 1..10 in MIDAS

title   squares

p==17
.vector pdl(lpdl==200)
ttyo==:5

start:  move    p, [-lpdl,,pdl-1]
        .open   ttyo, [.uao,,'tty ? 0 ? 0]
         .lose  %lsfil
        move    1, [-12,,1]
loop:   hrrz    2, 1
        imul    2, 2
        pushj   p, print
        movei   2, 15
        .iot    ttyo, 2
        movei   2, 12
        .iot    ttyo, 2
        aobjn   1, loop
        .logou  1,

print:  idivi   2, 12
        push    p, 3
        skipe   2
         pushj  p, print
        pop     p, 2
        addi    2, "0
        .iot    ttyo, 2
        popj    p,

end     start
Outputs the squares from 1 to 10.


 Hello World   MIPS R2000   Christian Heinig
.data                     # Datensegment
str:    .asciiz "Hello World!\n"  # String ablegen
        .text                     # Codesegment
main:   li      $v0, 4            # 4 = Print_string
        la      $a0, str          # Adresse des Strings übergeben
        syscall                   # Systemfunktion aufrufen
        li      $v0, 10           # 10 = Quit
        syscall                   # Programm beenden
Prints "Hello World" onto the screen.


 Hello World   Motorola 68000 (ATARI)   Michael Neumann
start:
        ; Message-String ausgeben
        move.l #msg,-(a7)
        move.w #9,-(a7)
        trap #1
        addq.l #6,a7

        ; auf Taste warten
        move.w #1,-(a7)
        trap #1
        addq.l  #2,a7

        ; Programm beenden
        clr -(a7)
        trap #1
         
        msg: dc.b "Hello World",10,13,0
Prints "Hello World" onto the screen.


 Hello World   VAX   Daniel Lundin
LL0:
        .data
        .text
L       .align  1
        .globl  _main
_main:
        .word   L12
        jbr     L14
L15:
        .data   1
L17:
        .ascii  "Hello, world.2"
        .text
        pushl   $L17
        calls   $1,_puts
        ret
        .set    L12,0x0
L14:
        jbr     L15
        .data
Prints "Hello World" onto the screen.






 awk    up
 
 


 Hello World   Michael Neumann
#
# Hello World in awk
#

BEGIN {
  print "Hello World"
}
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
function sqr(n) {
  return n*n
}

BEGIN {
  for(i=1; i<=10; i++) {
    printf "%d ", sqr(i) 
  }
  print    # new line
}
Outputs the squares from 1 to 10.






 BASIC    up
  similar languages: ABC   Amos   Euphoria   Profan   REXX  
 


 Hello World   Michael Neumann
PRINT "Hello World"
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
FOR I=1 TO 10
   PRINT I*I;
NEXT I
Outputs the squares from 1 to 10.






 BCPL    up http://www.tuxedo.org/~esr/jargon/html/entry/BCPL.html
 
  Description: BCPL (Basic Combined Programming Language) was developed by Martin Richards in Cambridge in 1967. The language C inherited some of BCPL's features, and in C++ BCPL's line comments (//) were introduced again.


 Hello World   Daniel Lundin
// BCPL 'Hello World' program

GET "LIBHDR"

LET START () BE
$(
    WRITES ("Hello World!*N")
$)               
Prints "Hello World" onto the screen.






 Befunge    up
 
 


 Squares (1)   Chad Fowler
55+82+*99*88*77*66*55*44*33*22*11*>v
                                  .:
                                  ^_@
Outputs the squares from 1 to 10. Note that formatting is important. Explanation: push 5, push 5, pop/pop/add/push, push 8, push 2, pop/pop/add/push, pop/pop/multiply, push, etc... (until ">") go right, go down, ":" means duplicate of stack, compare to 0--if 0 go right, otherwise left, go up ("^"), pop and print as integer (continue up), go left, go down (looping until "@" on nonzero condition, which means "end")


 Squares (2)   Chad Fowler
a987654321>v
          .:
          *v
          :v
          ^_@
Outputs the squares from 1 to 10. . Refactored :-)






 BETA    up
 
 


 Hello World   Michael Neumann
(#
do
   'Hello World' -> putline
#)
Prints "Hello World" onto the screen.


 Loop-Test   Michael Neumann
(#
   schleife:  (# n: @integer
              enter n
              do (for n repeat inner for)
              #)
do
   9 -> schleife  (#
                  do 10-n -> schleife (#
                                      do n -> putint; ' ' -> put
                                      #) newline
                  #)
#)
Prints following onto the screen:
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1



 Squares   Michael Neumann
(#
do
   (for i:10 repeat
      i*i -> putint
   for)
#)
Outputs the squares from 1 to 10.






 Blue    up
  similar languages: Eiffel   Sather  
 


 Hello World   Michael Neumann
-- Hello World in Blue

class HelloWorld is
==
== HelloWorld-Klasse
==
     
interface
   
    creation is
      == Erzeugt das HelloWorld-Objekt
      do
        printIt
      end creation

  routines

    printIt is
      == prints Hello World
      do
        print("Hello World\n")
      end printIt

end class
Prints "Hello World" onto the screen.






 Brain    up http://brain.sourceforge.net
 
  Description: "Brain is a high-level, purely object-oriented, prototype based scripting language mostly similar to the Self language. Some features of Brain are:
  • Everything is an object
  • Arbitrary precision numbers (using the gmp library)
  • Build-in high-level data structures
  • Automatic memory management (using a mark & sweep collector)
  • Closures
  • Exceptions
Brain is free software released under the GNU General Public License."


  Factorial   Michael Neumann
fac = {|n|
  (n > 1) if-true:  { n * fac (n-1) }
          if-false: { 1 }.
}.

-- call the code-block and output the value

fac (6); println. 
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
-- Hello World in Brain
#! this is also a single line comment
{- and a multi-liine
   comment. -}
  
"Hello World" println.
Prints "Hello World" onto the screen.


 Squares   Chad Fowler
#! Squares in Brain

1 to: 10 by: 1 do: { | i | (i * i) println. }
Outputs the squares from 1 to 10.






 BrainF*ck    up http://www.catseye.mb.ca/esoteric/bf/index.html
 
 


 Hello World   Jesse Crocker
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.---.+++++++..+++.>++++++++++++++++++++++++++++++++.<++++++++.--------.+
++.------.--------.>+.>++++++++++.
Prints "Hello World" onto the screen.


 Squares   Chad Fowler
+[>+[>+<-]<-] >> [>+<-]>[[>+>+<<-]>>[<<+>>-]<>+++++++++<[>>>+<<[>+>[-]<<
-]>[<+>-]>[<<++++++++++>>-]<<-<-]+++++++++>[<->-]<[>+<-]<[>+<-]<[>+<-]>>
>[<<<+>>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>>+<-]<<-
<-]>>>>[<<<<+>>>>-]<<<<>[-]<<+>]<[[>+<-]+++++++[<+++++++>-]<-><.[-]>>[<<
+>>-]<<-]>++++[<++++++++>-]<.[-] ++[>++[>+<-]<-] >> [>+<-]>[[>+>+<<-]>>[
<<+>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>-]<<-<-]++++
+++++>[<->-]<[>+<-]<[>+<-]<[>+<-]>>>[<<<+>>>-]<>+++++++++<[>>>+<<[>+>[-]
<<-]>[<+>-]>[<<++++++++++>>>+<-]<<-<-]>>>>[<<<<+>>>>-]<<<<>[-]<<+>]<[[>+
<-]+++++++[<+++++++>-]<-><.[-]>>[<<+>>-]<<-]>++++[<++++++++>-]<.[-] +++[
>+++[>+<-]<-] >> [>+<-]>[[>+>+<<-]>>[<<+>>-]<>+++++++++<[>>>+<<[>+>[-]<<
-]>[<+>-]>[<<++++++++++>>-]<<-<-]+++++++++>[<->-]<[>+<-]<[>+<-]<[>+<-]>>
>[<<<+>>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>>+<-]<<-
<-]>>>>[<<<<+>>>>-]<<<<>[-]<<+>]<[[>+<-]+++++++[<+++++++>-]<-><.[-]>>[<<
+>>-]<<-]>++++[<++++++++>-]<.[-] ++++[>++++[>+<-]<-] >> [>+<-]>[[>+>+<<-
]>>[<<+>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>-]<<-<-]
+++++++++>[<->-]<[>+<-]<[>+<-]<[>+<-]>>>[<<<+>>>-]<>+++++++++<[>>>+<<[>+
>[-]<<-]>[<+>-]>[<<++++++++++>>>+<-]<<-<-]>>>>[<<<<+>>>>-]<<<<>[-]<<+>]<
[[>+<-]+++++++[<+++++++>-]<-><.[-]>>[<<+>>-]<<-]>++++[<++++++++>-]<.[-]
+++++[>+++++[>+<-]<-] >> [>+<-]>[[>+>+<<-]>>[<<+>>-]<>+++++++++<[>>>+<<[
>+>[-]<<-]>[<+>-]>[<<++++++++++>>-]<<-<-]+++++++++>[<->-]<[>+<-]<[>+<-]<
[>+<-]>>>[<<<+>>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>
>+<-]<<-<-]>>>>[<<<<+>>>>-]<<<<>[-]<<+>]<[[>+<-]+++++++[<+++++++>-]<-><.
[-]>>[<<+>>-]<<-]>++++[<++++++++>-]<.[-] ++++++[>++++++[>+<-]<-] >> [>+<
-]>[[>+>+<<-]>>[<<+>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++
++>>-]<<-<-]+++++++++>[<->-]<[>+<-]<[>+<-]<[>+<-]>>>[<<<+>>>-]<>++++++++
+<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>>+<-]<<-<-]>>>>[<<<<+>>>>-]<<
<<>[-]<<+>]<[[>+<-]+++++++[<+++++++>-]<-><.[-]>>[<<+>>-]<<-]>++++[<+++++
+++>-]<.[-] +++++++[>+++++++[>+<-]<-] >> [>+<-]>[[>+>+<<-]>>[<<+>>-]<>++
+++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>-]<<-<-]+++++++++>[<->-
]<[>+<-]<[>+<-]<[>+<-]>>>[<<<+>>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]
>[<<++++++++++>>>+<-]<<-<-]>>>>[<<<<+>>>>-]<<<<>[-]<<+>]<[[>+<-]+++++++[
<+++++++>-]<-><.[-]>>[<<+>>-]<<-]>++++[<++++++++>-]<.[-] ++++++++[>+++++
+++[>+<-]<-] >> [>+<-]>[[>+>+<<-]>>[<<+>>-]<>+++++++++<[>>>+<<[>+>[-]<<-
]>[<+>-]>[<<++++++++++>>-]<<-<-]+++++++++>[<->-]<[>+<-]<[>+<-]<[>+<-]>>>
[<<<+>>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>>+<-]<<-<
-]>>>>[<<<<+>>>>-]<<<<>[-]<<+>]<[[>+<-]+++++++[<+++++++>-]<-><.[-]>>[<<+
>>-]<<-]>++++[<++++++++>-]<.[-] +++++++++[>+++++++++[>+<-]<-] >> [>+<-]>
[[>+>+<<-]>>[<<+>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>
>-]<<-<-]+++++++++>[<->-]<[>+<-]<[>+<-]<[>+<-]>>>[<<<+>>>-]<>+++++++++<[
>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>>+<-]<<-<-]>>>>[<<<<+>>>>-]<<<<>
[-]<<+>]<[[>+<-]+++++++[<+++++++>-]<-><.[-]>>[<<+>>-]<<-]>++++[<++++++++
>-]<.[-] ++++++++++[>++++++++++[>+<-]<-] >> [>+<-]>[[>+>+<<-]>>[<<+>>-]<
>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>-]<<-<-]+++++++++>[<
->-]<[>+<-]<[>+<-]<[>+<-]>>>[<<<+>>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+
>-]>[<<++++++++++>>>+<-]<<-<-]>>>>[<<<<+>>>>-]<<<<>[-]<<+>]<[[>+<-]+++++
++[<+++++++>-]<-><.[-]>>[<<+>>-]<<-]>++++[<++++++++>-]<.[-]
Outputs the squares from 1 to 10.






 C    up
  similar languages: C#   C++   C-Talk   D   Cilk   Java   Objective-C   Pike   TOM  
 


 Calculate PI   Michael Neumann
/*
 * Calculating PI
 *
 * Author: Michael Neumann (mneumann@fantasy-coders.de)
 * Date: 03.12.2002
 *
 * Requires GNU MP (tested with version 4.1) 
 * (http://www.swox.com/gmp/)
 *
 * To compile:
 *   cc pi.c -o pi -I/usr/local/include -L/usr/local/lib -lgmp
 */

#include "gmp.h"
#include <stdio.h>

int main(int argc, char **argv) {
  mpz_t k, a, b, a1, b1, p, q, d, d1;
  mpz_t t1, t2, t3, t4;  /* temporary */

  /* Initialize and assign integers */

  mpz_init(p);
  mpz_init(q);
  mpz_init(d);
  mpz_init(d1);
  mpz_init(t1);
  mpz_init(t2);
  mpz_init(t3);
  mpz_init(t4);
  mpz_init_set_ui(k, 2);
  mpz_init_set_ui(a, 4);
  mpz_init_set_ui(b, 1);
  mpz_init_set_ui(a1, 12);
  mpz_init_set_ui(b1, 4);

  for(;;) {
    /* Next approximation */

    mpz_mul(p, k, k);                   /* p = k * k */
    mpz_mul_ui(q, k, 2);                /* q = k * 2 */
    mpz_add_ui(q, q, 1);                /* q = q + 1 */
    mpz_add_ui(k, k, 1);                /* k = k + 1 */

    mpz_set(t1, a1);                    /* t1 = a1 */
    mpz_set(t2, b1);                    /* t2 = b1 */

    /* a1 = p*a + q*a1 */
    mpz_mul(t3, p, a);                  /* t3 = p * a */
    mpz_mul(t4, q, a1);                 /* t4 = q * a1 */
    mpz_add(a1, t3, t4);                /* a1 = t3 + t4 */

    /* b1 = p*b + q*b1 */
    mpz_mul(t3, p, b);                  /* t3 = p * b */
    mpz_mul(t4, q, b1);                 /* t4 = q * b1 */
    mpz_add(b1, t3, t4);                /* b1 = t3 + t4 */

    mpz_set(a, t1);
    mpz_set(b, t2);

    /* Print common digits */

    mpz_tdiv_q(d, a, b);                /* d = a / b */
    mpz_tdiv_q(d1, a1, b1);             /* d1 = a1 / b1 */

    while (mpz_cmp(d, d1) == 0) {       /* d == d1 */
      mpz_out_str(stdout, 10, d1);
      fflush(stdout);

      /* a = 10*(a mod b) */
      mpz_tdiv_r(t1, a, b);             /* t1 = a mod b */
      mpz_mul_si(a, t1, 10);            /* a = t1 * 10 */

      /* a1 = 10*(a1 mod b1) */
      mpz_tdiv_r(t1, a1, b1);           /* t1 = a1 mod b1 */
      mpz_mul_si(a1, t1, 10);           /* a = t1 * 10 */

      mpz_tdiv_q(d, a, b);              /* d = a / b */
      mpz_tdiv_q(d1, a1, b1);           /* d1 = a1 / b1 */
    }
  }

  return 0;
}
Calculating PI


 Hello World   Michael Neumann
#include <stdio.h>

main() {
   printf("Hello World\n");
}
Prints "Hello World" onto the screen.


 Multi-Threaded (forking) Echo-Server   Michael Neumann
/*
 * $Id: echo-mt.c,v 1.1 2002/01/09 14:28:43 michael Exp $
 *
 * Copyright (c) 2001, 2002 by Michael Neumann
 *
 * Multiple Threaded (forking) Echo-Server.
 *
 * Platform: NetBSD (should run on other Unices, too).
 *
 */

#include <sys/types.h>     /* htons() ... */
#include <sys/socket.h>    /* socket(), bind(), listen(), accept() */
#include <netinet/in.h>    /* sockaddr_in */

#include <sys/param.h>     /* MAXHOSTNAMELEN */
#include <netdb.h>         /* gethostbyname() */

#include <signal.h>        /* signal() */
#include <sys/wait.h>      /* waitpid() */

#include <unistd.h>        /* close(), gethostname(), read() ... */
#include <stdio.h>         /* perror() */
#include <strings.h>       /* bzero(), bcopy() */

#define PORT_NR 8000       /* port number to listen on */


/** 
 * Signal handler for SIGCHLD (child process changes state).
 *
 * Queries return status of terminated child processes, 
 * otherwise zombie processes will occure.
 */
void child_sig_handler(void) {
 while (waitpid(-1, NULL, WNOHANG) > 0)
   ;
}


int main(int argc, char** argv) {
  int s, t;                /* socket handles */
  struct sockaddr_in sa;   /* socket address */
  char myhostname[MAXHOSTNAMELEN+1]; /* local host name */
  struct hostent *hp;      /* host informations */

  int pid;      /* proccess id of forked child process */

  int count;
  char buffer[100];

  /* get host informations */
  gethostname(myhostname, MAXHOSTNAMELEN);
  if ( (hp = gethostbyname(myhostname)) == NULL ) {
    perror("Couldn't get informations about host name.");
    return -1;
  }

  /* initialize sockaddr_in struct */
  bzero(&sa, sizeof (struct sockaddr_in));
  bcopy(hp->h_addr, &sa.sin_addr, hp->h_length);
  sa.sin_family = hp->h_addrtype;
  sa.sin_port = htons(PORT_NR);

  /* create socket */
  if ( (s = socket(PF_INET, SOCK_STREAM, 0)) == -1 ) {
    perror("Couldn't create socket.");
    return -1;
  }

  /* bind socket `s' to specific address (local host) */
  if ( bind(s, (struct sockaddr*) &sa, sizeof (struct sockaddr)) == -1 ) {
    perror("Coudn't bind socket.");
    close(s);
    return -1;
  }

  /* allow incoming requests; queue up to 3 of them */
  listen(s, 3);


  /* install signal handler */
  signal(SIGCHLD, child_sig_handler);


  while (1) {

    /* accept a connection */
    if ( (t = accept(s, NULL, NULL)) == -1 ) {
      perror("Couldn't accept socket.");
      close(s);
      return -1;
    }

    /* fork new subprocess, which handles the new connection */
    switch (pid = fork()) {
    case -1:  /* error */
      perror("Could not fork!");
      close(s);
      close(t);
      return -1;

    case 0:   /* child process */
      /* close handle `s' as it is a duplicate */
      close(s);

      /* echo data */
      while ( (count = read(t, buffer, sizeof (buffer)-1)) > 0 ) {
         write(t, buffer, count);
      }

      /* close connection */
      close(t);
      return 0;

    default:  /* parent process */
      /* close handle `t' as it is a duplicate */
      close(t);
    }

  }

  close(s);
  return 0;
}
Implements a multi-threaded (forking) echo-server using BSD Sockets. Only tested on NetBSD!


 Single-Threaded (non-forking) Echo-Server   Michael Neumann
/*
 * $Id: echo-st.c,v 1.2 2002/01/09 14:29:03 michael Exp $
 *
 * Copyright (c) 2001, 2002 by Michael Neumann
 *
 * Single Threaded (non-forking) Echo-Server.
 *
 * Platform: NetBSD (should run on other Unices, too).
 *
 */

#include <sys/types.h>     /* htons() ... */
#include <sys/socket.h>    /* socket(), bind(), listen(), accept() */
#include <netinet/in.h>    /* sockaddr_in */

#include <sys/param.h>     /* MAXHOSTNAMELEN */
#include <netdb.h>         /* gethostbyname() */

#include <unistd.h>        /* close(), gethostname(), read() ... */
#include <stdio.h>         /* perror() */
#include <strings.h>       /* bzero(), bcopy() */

#define PORT_NR 8000       /* port number to listen on */


int main(int argc, char** argv) {
  int s, t;                /* socket handles */
  struct sockaddr_in sa;   /* socket address */
  char myhostname[MAXHOSTNAMELEN+1]; /* local host name */
  struct hostent *hp;      /* host informations */

  int count;
  char buffer[100];

  /* get host informations */
  gethostname(myhostname, MAXHOSTNAMELEN);
  if ( (hp = gethostbyname(myhostname)) == NULL ) {
    perror("Couldn't get informations about host name.");
    return -1;
  }

  /* initialize sockaddr_in struct */
  bzero(&sa, sizeof (struct sockaddr_in));
  bcopy(hp->h_addr, &sa.sin_addr, hp->h_length);
  sa.sin_family = hp->h_addrtype;
  sa.sin_port = htons(PORT_NR);

  /* create socket */
  if ( (s = socket(PF_INET, SOCK_STREAM, 0)) == -1 ) {
    perror("Couldn't create socket.");
    return -1;
  }

  /* bind socket `s' to specific address (local host) */
  if ( bind(s, (struct sockaddr*) &sa, sizeof (struct sockaddr)) == -1 ) {
    perror("Coudn't bind socket.");
    close(s);
    return -1;
  }

  /* allow incoming requests; queue up to 3 of them */
  listen(s, 3);

  while (1) {

    /* accept a connection */
    if ( (t = accept(s, NULL, NULL)) == -1 ) {
      perror("Couldn't accept socket.");
      close(s);
      return -1;
    }

    /* echo data */
    while ( (count = read(t, buffer, sizeof (buffer)-1)) > 0 ) {
       write(t, buffer, count);
    }

    /* close connection */
    close(t);
  }

  close(s);
  return 0;
}
Implements a single-threaded (non-forking) echo-server using BSD Sockets. Only tested on NetBSD!






 C#    up
  similar languages: C   C++   C-Talk   D   Cilk   Java   Objective-C   Pike   TOM  
  Description: C# (C sharp) is Microsofts answer to Suns Java. C# ties the speed and powerfulness of C++ and the high productivity of Visual Basic together. The only disadvantage of C# is the platform-dependency, because C# will probably only be available for Windows. C# has garbage-collection, but it is also possible to use pointer-arithmetric in special declared blocks and be responsible for the memory-removal. In C# all datatypes are objects, that is you can e.g. call a method on an integer. C# has build-in COM-functionality, so there are getter/setter-methods (properties) and events. Every C#-object is automatically a COM-object and because of that any other COM-object created in any language can be used. Altogether a very interesting language (especially for Windows-developer), wherby the change from C++ will not be very hard. Very interesting is the meta-documentation. To every element (class, method...) a documentation can be added, whereby the type of the documentation can be defined by C#-classes. You can access the documentation during runtime.


 Hello World   Michael Neumann
// Hello World in C#

using System;
class HelloWorld {
   static void Main() {
      Console.WriteLine("Hello World");
   }
}
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
using System;
class Squares1 {
   static void Main() {
      for (int i=1; i<=10; i++) {
         Console.WriteLine("{0} ", i*i);
      }
   }
}
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
using System;
class Squares2 {
   static void Main() {
      string res = "";
      int[] arr  = {1,2,3,4,5,6,7,8,9,10}; // short form for "new int[] = {1,2,...}"
      
      for (int i=0; i<arr.Length; i++) {
         res += (arr[i]*arr[i]).ToString() + " ";
      }
      Console.WriteLine("{0}", res);
   }
}
Outputs the squares from 1 to 10.






 C++    up
  similar languages: C   C#   C-Talk   D   Cilk   Java   Objective-C   Pike   TOM  
  Description: C++ was developed in 1980 (1983 the name C++ was born) by Bjarne Stroustrup. C++ is a superset of C, i.e. C++ includes the whole syntax of C and extends this for object-oriented features which came from Simula (67). Today, C++ is the most popular language.


 Boyer-Moore Search   Michael Neumann
/*
 *  Boyer-Moore Search
 *
 *  01.06.1998, implemented by Michael Neumann
 */

# include <algorithm>

int BoyerMooreSearch(char* text, char* muster, int tlen, int mlen)
{
  int i, j, skip[256];

  for(i=0; i<256; ++i)  skip[i]=mlen;
  for(i=0; i<mlen; ++i) skip[muster[i]]=mlen-1-i;

  for(i=j=mlen-1; j>=0; --i, --j)
    while(text[i] != muster[j]) {
      i += max(mlen-j,skip[text[i]]);
      if(i >= tlen) return -1;
      j = mlen-1;
    }
  return i;
}
A very good algorithm to search for an occurence of a substring in a string.


 BubbleSort   Michael Neumann
/*
 *  BubbleSort
 *
 *  20.11.1998, implemented by Michael Neumann (mneumann@ntecs.de)
 */

# ifndef __BUBBLESORT_HEADER__
# define __BUBBLESORT_HEADER__

# include <algorithm>

template <class itemType, class indexType=int>
void BubbleSort(itemType a[], indexType l, indexType r)
{
  static indexType i, j;

  for(i=r; i>l; --i)
    for(j=l; j<i; ++j)
      if(a[j] > a[j+1]) std::swap(a[j], a[j+1]);
}

# endif
BubbleSort


 BucketSort   Michael Neumann
/*
 *  BucketSort (Distrubution Counting)
 *
 *  21.11.1998, implemented by Michael Neumann (mneumann@ntecs.de)
 */

# ifndef __BUCKETSORT_HEADER__
# define __BUCKETSORT_HEADER__

# include <algorithm>


// itemType must have an typecast to "int", which identifies the sortkey
template <class itemType, class indexType=int>
class BucketSort {
  public:

    // the array b[] had to be the same size like a[]
    void Sort(itemType a[], itemType b[], indexType l, indexType r) {
      a = &a[l]; b = &b[l];
      for(int i=0; i<sizeof(int); ++i) {
        sort_byte(i,a,b,r-l+1);
        std::swap(a,b);
      }
    }

  protected:

    sort_byte(int bytenr, itemType a[], itemType b[], indexType count) {
      static indexType i;
      typedef unsigned char* UCP;

      for(i=0; i<256; ++i) occurences[i] = 0;   // better: memset
      for(i=0; i<count; ++i) ++occurences[((UCP)&a[i])[bytenr]];
      for(i=1; i<256; ++i) occurences[i] += occurences[i-1];
      for(i=count-1; i>=0; --i)
        b[--occurences[((UCP)&a[i])[bytenr]]] = a[i];
    }

    int occurences[256];
};

# endif
BucketSort


 gcd   Michael Neumann
/*
    Größter Gemeinsamer Teiler

    Es sind nur Werte größer als Null zulässig.
*/

int ggt( int a, int b )
{
  int temp;
  if( a < b ) { temp=a; a=b; b=temp; }
  while( (temp = a%b) != 0 )
  {
    a = b;
    b = temp;
  };
  return b;
}
Greatest common divisor


 Hash1   Michael Neumann
/*
 *  Hash1.Cpp
 *
 *  03.06.1998, implemented by Michael Neumann
 */

int hash1(int M, char* t)
{
  unsigned h=0;
  for(;*t;++t) h = ((h << 8)+ *t) % M;
  return h;
}
Standard Hash Function


 hashpjw   Michael Neumann
/*
 *  hashpjw, algorithm by P.J.Weinberg
 *
 *  03.06.1998, implemented by Michael Neumann
 */

int hashpjw(int M, char* t)
{
  unsigned h=0, g;
  for(;*t;++t) {
    h = (h << 4)+ *t;
    if(g=h&0xf0000000) {
      h ^= g>>24;
      h ^= g;
    }
  }
  return h%M;
}
Hashfunction of P.J. Weinberg


 Hello World (1)   Michael Neumann
#include <stdio.h>

int main(int argc, char *argv[])
{
   printf("Hello World\n");
   return 0;
}
Prints "Hello World" onto the screen.


 Hello World (2)   Michael Neumann
#include <iostream.h>

int main(int argc, char *argv[])
{
   cout << "Hello World" << endl;
   return 0;
}
Prints "Hello World" onto the screen.


 Hello World (standard)   Daniel Kress
#include <iostream>
using namespace std;

int main()
{
   cout << "Hello World" << endl;
   return 0;
}
Prints "Hello World" onto the screen.


 InsertionSort   Michael Neumann
/*
 *  InsertionSort
 *
 *  20.11.1998, implemented by Michael Neumann (mneumann@ntecs.de)
 */

# ifndef __INSERTIONSORT_HEADER__
# define __INSERTIONSORT_HEADER__

# include <algorithm>

template <class itemType, class indexType=int>
void InsertionSort(itemType a[], indexType l, indexType r)
{
  static indexType i, j;
  static itemType v;

  for(i=l+1; i<=r; ++i) {
    for(j=i-1, v=a[i]; j>=l && a[j]>v; a[j+1]=a[j], --j);
    a[j+1] = v;
  }
}

# endif
InsertionSort


 MergeSort   Michael Neumann
/*
 *  MergeSort
 *
 *  21.11.1998, implemented by Michael Neumann (mneumann@ntecs.de)
 */

# ifndef __MERGESORT_HEADER__
# define __MERGESORT_HEADER__

# include <algorithm>

// Array b[] must have same size like a[]; result is in a[]!
template <class itemType, class indexType=int>
void MergeSort(itemType a[], itemType b[], indexType l, indexType r)
{
  indexType i, j, k, m;

  if(r > l) {
    m = (r+l)/2;
    MergeSort(a,b,l,m);
    MergeSort(a,b,m+1,r);
    for(i=m+1; i>l; --i) b[i-1] = a[i-1];
    for(j=m; j<r; ++j) b[r+m-j] = a[j+1];
    for(k=l; k<=r; ++k) a[k] = (b[i] < b[j]) ?  b[i++] : b[j--];
  }
}

# endif
MergeSort


 QuickSort   Michael Neumann
/*
 *  QuickSort, algorithm by C.A.R. Hoare (1960)
 *
 *  01.06.1998, implemented by Michael Neumann (mneumann@ntecs.de)
 */

# ifndef __QUICKSORT_HEADER__
# define __QUICKSORT_HEADER__

# include <algorithm>

template <class itemType, class indexType=int>
void QuickSort(itemType a[], indexType l, indexType r)
{
  static itemType m;
  static indexType j;
  indexType i;

  if(r > l) {
    m = a[r]; i = l-1; j = r;
    for(;;) {
      while(a[++i] < m);
      while(a[--j] > m);
      if(i >= j) break;
      std::swap(a[i], a[j]);
    }
    std::swap(a[i],a[r]);
    QuickSort(a,l,i-1);
    QuickSort(a,i+1,r);
  }
}

# endif
QuickSort


 SelectionSort   Michael Neumann
/*
 *  SelectionSort
 *
 *  20.11.1998, implemented by Michael Neumann (mneumann@ntecs.de)
 */

# ifndef __SELECTIONSORT_HEADER__
# define __SELECTIONSORT_HEADER__

# include <algorithm>

template <class itemType, class indexType=int>
void SelectionSort(itemType a[], indexType l, indexType r)
{
  static indexType i, j, min;

  for(i=l; i<r; ++i) {
    for(min=i, j=i+1; j<=r; ++j) if(a[j] < a[min]) min = j;
    std::swap(a[min], a[i]);
  }
}

# endif
SelectionSort


 ShellSort   Michael Neumann
/*
 *  ShellSort
 *
 *  20.11.1998, implemented by Michael Neumann (mneumann@ntecs.de)
 */

# ifndef __SHELLSORT_HEADER__
# define __SHELLSORT_HEADER__

# include <algorithm>

template <class itemType, class indexType=int>
void ShellSort(itemType a[], indexType l, indexType r)
{
  static indexType i, j, h;
  static itemType v;

  for(h=1; h<=(r-l)/9; h=3*h+1);
  for(; h>0; h/=3) {
    for(i=l+h; i<=r; ++i) {
      for(j=i-h, v=a[i]; j>=l && a[j]>v; a[j+h]=a[j], j-=h);
      a[j+h] = v;
    }
  }
}

# endif
ShellSort


 Hello World (1)   DOS/Windows   Michael Neumann
#include <stdio.h>

void main()
{
   printf("Hello World\n");
}
Prints "Hello World" onto the screen.


 Hello World (2)   DOS/Windows (obsolete C++)   Michael Neumann
#include <iostream.h>

void main()
{
   cout << "Hello World" << endl;
}
Prints "Hello World" onto the screen.






 Cilk    up
  similar languages: C   C#   C++   C-Talk   D   Java   Objective-C   Pike   TOM  
 


 Hello World   Michael Neumann
#include <stdio.h>

cilk void main()
{
   printf("Hello World\n");
}
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
/* Cilk ist fast C */

#include <stdio.h>

cilk void main()
{
   int i;
   
   for(i = 1; i <= 10; ++i) printf("%d ", i*i);   
}
Outputs the squares from 1 to 10.






 CLAIRE    up
 
 


 Hello World   Michael Neumann
;; Hello World in CLAIRE

[ main() -> printf("Hello World\n") ]
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
[

main() ->
   for i in (1 .. 10) printf("~S ",i * i)

]
Outputs the squares from 1 to 10.






 Clipper    up
 
 


 Hello World   Pablo Romero
? "Hello World"
quit
Prints "Hello World" onto the screen.


 Squares   Jürgen Müller
for nI := 1 TO 10
 ? nI*nI
next
Outputs the squares from 1 to 10.






 COBOL    up
 
 


 Hello World   Fabritius
IDENTIFICATION DIVISION.
PROGRAM-ID. HelloWorld.
AUTHOR. Fabritius.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.

DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
LINKAGE SECTION.

PROCEDURE DIVISION.
DISPLAY "Hello World".
STOP RUN. 
Prints "Hello World" onto the screen.






 Concurrent Clean    up http://www.cs.kun.nl/~clean/
 
  Description: Clean is a pure functional, lazy evaluating programming language (similar to Haskell).

Features:

  • Uniqueness typing: Allows descructive updates on objects with only one reference (prepend a '*')
  • Pure functional, lazy evaluating
  • Strict annotations (prepend a '!')
  • Existential types: Hides the type inside an object (encapsulation, allows OO-like programming)
  • Records, arrays, unboxed arrays
  • Generates highly optimized assembly code
  • Comes with an IDE and a platform-independent GUI (currently only on Windows and Mac)
  • Complete sources of the Clean IDE, compiler etc.. available
  • Free for non-commercial use




 Ackermann   Michael Neumann
//
// File:     Ackermann 
// Language: Concurrent Clean 2.0 
// Author:   Michael Neumann (mneumann@ntecs.de)
// Date:     23 March 2002
//

module Ackermann

import StdEnv
import ArgEnv

Ack :: !Int !Int -> !Int
Ack 0 n = n+1
Ack m 0 = Ack (m-1) 1
Ack m n = Ack (m-1) (Ack m (n-1))

Start :: String
Start = "Ack(3," +++ toString n +++ "): " +++ toString (Ack 3 n) +++ "\n"
      where n = toInt (select getCommandLine 1)
Calculates the Ackermann function


 Array Access   Michael Neumann
//
// File:     Array Access 
// Language: Concurrent Clean 2.0 
// Author:   Michael Neumann (mneumann@ntecs.de)
// Date:     24 March 2002
//

module ArrayAccess

import StdEnv
import ArgEnv

RUNS :== 1000

doIt x y lix =
  loop RUNS y
where
  // loop 'i' times
  loop :: !Int *{#Int} -> *{#Int}
  loop i y
    # y` = add lix y
    | i <= 1    = y`
    | otherwise = loop (i-1) y`
  where
    // adds 'x' to 'y'
    add :: !Int *{#Int} -> *{#Int}
    add i y
      #! e  = y.[i]
      #  y` = {y & [i] = e + x.[i]}
      |  i == 0    = y`
      |  otherwise = add (i-1) y`

Start :: String
Start
  # a = doIt (make_x n) (make_y n) (n-1)
  = toString a.[0] +++ " " +++ toString a.[n-1] +++ "\n"
where
  n = toInt (select getCommandLine 1)

  // creates the 'x' array
  make_x :: !Int -> *{#Int}
  make_x n = fill_x (createArray n 0) (n-1)
  where
    fill_x :: *{#Int} !Int -> *{#Int}
    fill_x x i
      | i == 0     = x`
      | otherwise  = fill_x x` (i-1)
    where
      x` = {x & [i] = i+1}

  // creates the 'y' array
  make_y :: !Int -> *{#Int}
  make_y n = createArray n 0



  Factorial   Michael Neumann
module Fac

fac :: !Int -> Int
fac 0 = 1
fac 1 = fac 0
fac n = n * fac (dec n)


// Tail recursive (much faster)
fact :: !Int !Int -> Int
fact 0 i = i
fact n i = fact (n-1) (n*i)



 Fibonacci   Michael Neumann
//
// File:     Fibonacci 
// Language: Concurrent Clean 2.0
// Author:   Michael Neumann (mneumann@ntecs.de)
// Date:     23 March 2002
//

module Fibonacci

import StdEnv
import ArgEnv

Fib :: !Int -> !Int
Fib n
    | n < 2     = 1
    | otherwise = Fib (n-2) + Fib (n-1)

Start :: String
Start = "Fib(" +++ toString n +++ "): " +++ toString (Fib n) +++ "\n"
      where n = toInt (select getCommandLine 1)



 Hello World   Michael Neumann
// Hello World

module helloworld
import StdEnv

Start :: String
Start = "Hello World"
Prints "Hello World" onto the screen.


 Hello World   Michael Neumann
module HelloWorld

Start = "Hello World\n"
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
module squares
import StdEnv

Start :: [(Int, String)]
Start = [(a*a," ") \\ a <- [1..10]]
Outputs the squares from 1 to 10.


 String Concatenation   Michael Neumann
//
// File:     String Concatenation 
// Language: Concurrent Clean 2.0 
// Author:   Michael Neumann (mneumann@ntecs.de)
// Date:     25 March 2002
//

module StringConcatenation

import StdEnv
import ArgEnv

loop :: !Int *String -> *String
loop 0 s = s
loop i s = loop (i-1) (s +++. "hello\n")

Start = toString (size s) +++ "\n"
where
  s = loop n ""
  n = toInt (select getCommandLine 1)
Appends n-times the string "hello\n".






 Cook    up http://www.canb.auug.org.au/~millerp/cook
 
  Description: Cook is a Dependency Maintenance Tool (DMT) and is used for constructing files from other, dependent files. It's purpose is similar to the popular UNIX 'make', but has more features and is easier to use. Cook has true variables (not simple macros as in 'make'); user defined functions; is very portable due to a lot of built-in functions; can build in parallel even across a network; doesn't use tabs to indent (as 'make' uses); can simply be told to use fingerprints (e.g. using a MD5 checksum) instead of timestamps.


 Hello World   Michael Neumann
/* Hello World in Cook */

/* platform-independent using built-in function */
[print "Hello World"];

/* platform-dependent using `echo' */
echo "Hello World";
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
/** 
 *
 * start from the command-line with:
 *
 *   cook -Book squares.cook
 * 
 * or rename as Howto.cook and invoke:
 * 
 *   cook 
 * 
 * Note that `expr' is a build-in cook command, 
 * and not the UNIX /bin/expr program. 
 * The same applies to `print'.   
 */

loop n = 1 2 3 4 5 6 7 8 9 10
{
  [print [expr [n] * [n]]];
}
Outputs the squares from 1 to 10.






 COSY INFINITY    up http://cosy.nscl.msu.edu
 
 


 Hello World   Michael Neumann
{ Hello World in COSY }

BEGIN ;
   WRITE 6 'Hello World' ;   { 6 ist Stdout }
END ;
Prints "Hello World" onto the screen.






 C-Talk    up
  similar languages: C   C#   C++   D   Cilk   Java   Objective-C   Pike   TOM  
  Description: C-Talk is an object-oriented language with strong static typing, multiple-inheritance, parameterized classes (templates), exceptions, multi-tasking, persistent objects and garbage-collection instead of explicit (manual) memory-removal. C-Talk inherits best features from languages like C++, Smalltalk, Lisp, CLU.


 Eulersche Number (1)   Michael Neumann
(* e = Summe der Reziproken der Fakultäten *)



// Fakultäts-Funktion
function fac( int n ) returns int
{
   if( n > 1 ) return n * fac(n-1);
   else return 1;
}


var arr := [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ];


// filter_arr wendet die übergebene Funktion auf jedes Element des 
// Arrays arr an und schreibt den Rückgabewert zurück ins Array
function filter_arr ( proc(float) returns float transform ) {
   for( var i := 0 ; i < 10; i := i + 1 ) {
      arr[i] := transform(arr[i]);
   }
}


// Fakultäten berechnen
// lambda erzeugt eine namenlose Funktion
// -> ist ein typecast
filter_arr( lambda(float x) returns float { return fac(x -> int) -> float; } );

// Reziproken berechnen
filter_arr( lambda(float x) returns float { return 1.0 / x; } );

// Summe bilden
var float e := 0.0;
filter_arr( lambda(float x) returns float { e := e + x; return x; } );


// e ausgeben
cout << e;
Calculates the eulersche-number (e=2.71828).


 Eulersche Number (2)   Michael Neumann
// Fakultäts-Funktion
function fac( int n ) returns int
{
   if( n > 1 ) return n * fac(n-1);
   else return 1;
}

var e := 0.0;

for( var n := 0; n < 10; n := n + 1 ) {
   e := e + 1.0 / fac(n) -> float;
}



// e ausgeben
cout << e;
Calculates the eulersche-number (e=2.71828).


 Factorial   Michael Neumann
/* 
 * Berechnen der Fakultät
 */


function fac( int n ) returns int
{
   if( n > 1 ) return n * fac(n-1);
   else return 1;
}


// Funktion aufrufen
cout << fac(6);
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
// Hello World in C-Talk

cout << "Hello World\n";
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
(*
 * Squares (* geschachtelter Kommentar *)
 *)


for( var int i:=1; i<=10; i:=i+1 )
{
   cout << i * i << " ";
}
Outputs the squares from 1 to 10.






 Curl    up www.curl.com
 
 


 Hello World   Brent A. Young
{curl 1.7 applet}
{applet license = "personal"}
Hello World
Prints "Hello World" onto the screen.






 Cyclone    up http://www.research.att.com/projects/cyclone/
 
  Description: Cyclone is a safe dialect of C. It has lots of other features not found in C, e.g. tagged unions, ML-style datatypes, parametric polymorphism, pattern matching and exceptions.


 Hello World   Michael Neumann
#include <stdio.h>

int main() {
  printf("Hello World\n");
  return 0;
}
Prints "Hello World" onto the screen.






 D    up http://www.digitalmars.com/d/index.html
  similar languages: C   C#   C++   C-Talk   Cilk   Java   Objective-C   Pike   TOM  
  Description:

Features:

  • Garbage Collection (automatic memory management).
  • Modules (similar to Java packages); this makes C's header files superfluous and reduces compile-time dramatically for large projects (this also reduces code duplication).
  • Contracts (Design by Contract - DbC); Invariants, Pre- and Postconditions.
  • For each class, a unit-test can be specified.
  • Built-in strings, arrays (dynamically-sized, as well as static array as in C), associative arrays (hashs/dictionaries).
  • Single inheritance with interfaces (like Java).
  • Synchronization keywords (like Java).
  • C functions can be accessed directly from D.
  • Inline assembler.
  • Versioning (replaces #if directives).
  • Stronger typecheching than in C/C++.
  • Exception handling (throw/try-catch-finally).
  • Array slicing.
  • Setter/getter methods for object-properties (e.g. a.text = ... or ... = a.text).
  • No preprocessor/macros neccessary.
  • Win32-specific: D objects are compatible with COM-objects (similar to C#).
Negative Aspects:
  • No (not yet?) generic classes (templates).
  • Not yet (?) open source.
  • Still a "beta"-release; language and compiler not yet as mature as other languages (no standard like C, C++ or C#).
  • No port for Unix available (but a D to C converter is in work).
  • Strong overloading restictions (this is why D uses printf instead of C++'s counterpart cout).








 dBASE    up
 
 


 Hello World   Pablo Romero
? "Hello World"
return
Prints "Hello World" onto the screen.






 DOS Batch    up
  similar languages: Shell-Sprachen  
 


 Hello World   Michael Neumann
@ECHO OFF
ECHO Hello World
Prints "Hello World" onto the screen.


 Numbers   Michael Neumann
@ECHO OFF

REM Gibt die Zahlen 0-99 aus
REM Diese Datei muß numbers.bat heißen

IF "%1" == ""       GOTO outer
IF "%1" == "output" GOTO output
IF "%1" == "inner"  GOTO inner
GOTO exit


:inner
FOR %%i IN (0 1 2 3 4 5 6 7 8 9) DO CALL numbers output %2 %%i
GOTO exit


:outer
FOR %%i IN (0 1 2 3 4 5 6 7 8 9) DO CALL numbers inner %%i
GOTO exit


:output
IF "%2" == "0" ECHO %3
IF NOT "%2" == "0" ECHO %2%3


:exit
Prints the numbers from 0 to 99.






 Dylan    up http://www.gwydiondylan.org/
 
  Description: Features:
  • Dylan is a functional language (every statement has a value).
  • Purely object oriented (every value is an object, much like Smalltalk).
  • Supports static as well as dynamic type checking (optional type declarations => rapid prototyping).
  • Support for incremental compilation.
  • First class functions and classes.
  • Garbage Collection (automatic memory managagement).
  • Multi-methods (methods that can work on objects of multiple classes). Methods are not bound to classes (generic functions). Classes only contain data and encapsulate it.
  • Multiple Inheritance.
  • Modules (for visibility of variables, functions and classes).
  • Macros. They are evaluated by the compiler; i.e. they know the syntax and do not simply substitute text.
  • Slot accessors are automatically defined (no need to declare get_x and set_x for member variable x).
  • Class variables and virtual variables (on each access a function is called).
  • Keyword arguments.
  • Comes with an interfacing system to call C functions.
  • Implementations available for Windows, Apple and UNIX; free and commercial versions available.
  • Identifiers can use many characters (not just A-Z, a-z, 0-9 and _, but also -, ?, $ and more).
  • Identifier naming convention: $xxx is a constant; <xxx> is a class; xxx? is a method returning a boolean; xxx! is a destructive method; use - to delimit words, e.g. get-line (instead of getLine or get_line).
  • Identifiers are case-insensitive.
  • Integers of unlimited size are part of Dylan.


 Hello World   Michael Neumann
define method hello-world()
      format-out("Hello World\n");       
end method hello-world;

hello-world();
Prints "Hello World" onto the screen.


 OO - Shape, Circle, Rectangle   Michael Neumann
module: shape
synopsis: OO - Shape, Circle, Rectangle 
author: Michael Neumann
copyright: Copyright (c) 2002, Michael Neumann 

// note:
//   last two words after "end" are optional
//   all type specifiers after "::" are optional

define class <color> (<object>)
  slot red :: <number>,
    init-value: 0,
    init-keyword: red:;
  slot green :: <number>,
    init-value: 0,
    init-keyword: green:;
  slot blue :: <number>,
    init-value: 0,
    init-keyword: blue:;
end class <color>;

define class <shape> (<object>)
  slot x :: <number>,
    required-init-keyword: x:;
  slot y :: <number>,
    required-init-keyword: y:;
  slot color :: <color>,
    required-init-keyword: color:;
end class <shape>;

define class <circle> (<shape>)
  slot radius :: <number>,
    required-init-keyword: radius:;
end class <circle>;

define class <rectangle> (<shape>)
  slot width :: <number>,
    required-init-keyword: width:;
  slot height :: <number>,
    required-init-keyword: height:;
end class <rectangle>;

/* Define the methods */

define method move(shape :: <shape>, xo :: <number>, yo :: <number>)
  shape.x := shape.x + xo;
  shape.y := shape.y + yo;
end method move;

define method draw(shape :: <shape>)
  // do something here
end method draw;

define method get-area(circle :: <circle>)
 => (area :: <number>)
  3.1415 * circle.radius;
end method get-area;

define method get-area(rectangle :: <rectangle>)
 => (area :: <number>)
  rectangle.width * rectangle.height;
end method get-area;

/* Test the classes */

define constant $black :: <color> =
  make(<color>);

define constant $white :: <color> =
  make(<color>, red: 255, green: 255, blue: 255);

define variable circle :: <circle> =
  make(<circle>, x: 100, y: 100, radius: 50, color: $black);

define variable rect :: <rectangle> =
  make(<rectangle>, x: 20, y: 20, width: 5, height: 5, color: $white);


move(circle, 10, 10);

circle.x := 50;
circle.radius := 5;

format-out("%=\n", get-area(circle));  // => 15
format-out("%=\n", get-area(rect));    // => 25

format-out("%=\n", rect.width);        // => 5
width-setter(10, rect);                // another way to set a slot
format-out("%=\n", width(rect));       // => 10

draw(circle);
draw(rect);



 Squares   Michael Neumann
for (i :: <integer> from 1 to 10)
      format-out("%d ",i * i);
end for;
Outputs the squares from 1 to 10.






 E    up http://www.erights.org
 
 


 Hello World   Michael Neumann
# Hello World in E
// by Michael Neumann

println( "Hello World" )
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
for i in 1..10 {
   print( i*i )
   print( " " )
}
Outputs the squares from 1 to 10.






 Eiffel    up
  similar languages: Blue   Sather  
 


 Hello World   Michael Neumann
indexing
        title:  "Hello World";        
        author: "Michael Neumann";
        
class MAIN creation
        make
                
feature
        make is
        do
           io.put_string("Hello World");
           io.new_line
        end -- make
end -- class MAIN
Prints "Hello World" onto the screen.


 Hello World   SmallEiffel   Michael Neumann
-- 
-- compile with: smalleiffel compile helloworld
-- 
indexing
   title: "Hello World";
   author: "Michael Neumann";

class HELLOWORLD

creation {ANY}
   make

feature {ANY}

   make is
      do
         std_output.put_string("Hello World");
         std_output.put_new_line;
      end -- make

end -- class HELLOWORLD
Prints "Hello World" onto the screen.






 Emerald    up
 
 


 Hello World   Michael Neumann
const HelloWorld ==

%
% Hello World in Emerald
%

   object HelloWorld
      process
         stdout.putstring["Hello World\n"]
         stdin.close
         stdout.close
      end process
   end HelloWorld
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
const Test ==

   object Test
      process
         var i : Integer         

         i <- 1

         loop
            exit when (i>10)
            
            stdout.putint[i*i] 
            stdout.putstring[" "]
         end loop
     
         stdin.close
         stdout.close
      end process
   end Test
Outputs the squares from 1 to 10.






 Erlang    up http://www.erlang.org
 
 


 Hello World   Michael Neumann
io:fwrite("Hello World~n").    %% im Eingabemodus
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
%%
%% language: Erlang 4.7.3
%% author:   Michael Neumann
%% file:     test.erl
%%

-module(test).
-export([main/1]).

main(0) -> [];

main(N) -> main(N-1),
           io:fwrite("~w ",[N*N]).


%% Eingabemodus:
c("test.erl").   %% lädt test.erl
test:main(10).
Outputs the squares from 1 to 10.






 Euphoria    up
  similar languages: ABC   Amos   BASIC   Profan   REXX  
 


  Discouragement example    Johann Dieter R.
-- abschreckendes Beispiel fuer HELLO WORLD! (jdr, 19.10.2000)
--

--
-- Diese Routine arbeitet mit dem Software-Interrupt #0E der Video-
-- BIOS-Services (#10) ("WRITE TEXT IN TELETYPE MODE").

include machine.e                       -- benoetigte Include

global integer forecol                  -- Textfarbe

global object instruc                   -- Objekt für die Werte,
                                        -- mit denen der Software-
                                        -- Interrupt angesprochen
                                        -- wird.

forecol = 7

instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 72,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 101,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 108,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 108,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 111,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 32,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 87,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 111,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 114,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 108,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 100,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 33,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 10,0,0,0})
instruc = dos_interrupt(#10,{0,0,0,forecol,0,0,#0E00 + 13,0,0,0})
This example only serves as discouragement!


 Hello World   Michael Neumann
puts (1, "Hello World\n")
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
for i=1 to 10 do
   print(1,i*i)
   puts(1," ")
end for
Outputs the squares from 1 to 10.






 FISh    up http://www-staff.it.uts.edu.au/~cbj/FISh/index.html
 
  Description: FISh is a functional language with imperativ features. The FISh compiler is written in OCaml and the generated code is high-performant C sourcecode. If you believe in the benchmark results (I do!), quicksort written in FISh is more than twice as fast as the qsort routine of the C standard library (because C uses pointers whereas FISh does not).


 Hello World   Michael Neumann
(* Hello World in FISh *)

output "Hello World" ;;
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
for 1 <= i < 11 do output (i*i) done;;
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
(* function sqr *)
let sqr x = x * x ;;

(* array with 10 integers *)
let a = fill { 10 : int_shape } with [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ;;

(* apply function sqr onto every element of array a *)
let res = map sqr a;; 

output res;;
Outputs the squares from 1 to 10.






 FOP    up
 
  Description: Seit vielen Jahren gibt es unter Unix für die betriebswirtschaftliche Software auch eine Scriptsprache names FOP (Flexible Oberflächenprogrammierung) um diese Software anzupassen.


 Hello World   olios@gmx.de
.box
Hello world !!!
.ende
Prints "Hello World" onto the screen.






 Forth    up http://www.forth.org
  similar languages: Postscript  
 


 CGI Squares   Michael Neumann
\ #! /usr/bin/env gforth

: HTTP-HEADER
  ." Content-type: text/html"
  CR
  CR
;

: <HTML>   ." <HTML>" ;
: </HTML>  ." </HTML>" ;
: <HEAD>   ." <HEAD>" ;
: </HEAD>  ." </HEAD>" ;
: <TITLE>  ." <TITLE>" ;
: </TITLE> ." </TITLE>" ;
: <BODY>   ." <BODY>" ;
: </BODY>  ." </BODY>" ;
: <P>      ." <P>" ;
: </P>     ." </P>" ;
: <BR>     ." <BR> " ;
: <H1>     ." <H1>" ;
: </H1>    ." </H1>" ;

\ ============================

: squares()
  11 1 DO I DUP * . <BR> LOOP
;

\ ============================

HTTP-HEADER

<HTML>
<HEAD>
  <TITLE> ." CGI-Squares in Forth" </TITLE>
</HEAD>
<BODY>
  <H1> ." CGI-Squares in Forth" </H1>

  squares()

</BODY>
</HTML>

bye
CGI - Outputs the squares from 1 to 10.


  Discouragement example    Michael Neumann
10000 constant ztsd  variable zs  2variable tr
: zins ztsd m/mod swap zs @ ztsd */ swap zs @ 1 */ + 1 m* ;
: restd1 2dup zins d+ tr 2@ d- ; ( d -- d )
: restd 0 do restd1 loop ; ( d -- d )
: tdauer 0 >r 2dup zins tr 2@ d< if begin r> 1 + >r restd1 2dup tr 2@ d< until
2dup d0= if 0 else 1 then r> + else ." keine Tilgung " then ; ( d -- d n )
This example only serves as discouragement!


 Hello World (1)   Michael Neumann
( Hello World in Forth )

." Hello World"
Prints "Hello World" onto the screen.


 Hello World (2)   Michael Neumann
\ Hello World in Forth

: say_hello ." Hello World" ;
say_hello
Prints "Hello World" onto the screen.


  Loop-Test   Michael Neumann
: IS 0 DO I . LOOP ;
: AS 0 DO CR 1 - DUP IS LOOP ;

11 10 AS
Prints the following onto the screen:
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6
0 1 2 3 4 5
0 1 2 3 4
0 1 2 3
0 1 2
0 1
0



 Squares   Michael Neumann
: squares    ( to from    -->           )

  SWAP       ( to from    -->  from to   )
  1 +        ( from to    -->  from to+1 )
  SWAP       ( from to+1  -->  to+1 from )

  DO
    I DUP * .
  LOOP
;

10 1 squares
Outputs the squares from 1 to 10.


  Absolute value   ANS Forth   Michael Neumann
: abs ( value -- value' ) DUP 0< IF NEGATE ENDIF ;



  Factorial   ANS Forth   Michael Neumann
\ define function (definiere Funktion)

: FAC recursive       ( n-n)
  DUP 1 >
  IF                  \ if n > 1
    DUP 1 - FAC *     \   n * fac n-1
  ELSE                \ else 
    DROP 1            \   1 
  ENDIF               \ end 
;

\ call function (Funtkion aufrufen)

6 FAC .
Calculates the factorial. Results 720.


  Factorial   ANS Forth, pForth   Michael Neumann
\ define function (definiere Funktion)

: FAC                   ( n-n)
  DUP 1 >
  IF                    \ if n > 1
    DUP 1 - RECURSE *   \   n * fac n-1
  ELSE                  \ else 
    DROP 1              \   1 
  THEN                  \ end 
;

\ call function (Funtkion aufrufen)

6 FAC .
Calculates the factorial. Results 720.






 Fortran    up
 
 


 Hello World   Fortran 77   Michael Neumann
*
C Hello World in Fortran 77
C (lines must be 6 characters indented)
*
      PROGRAM HELLOW
      WRITE(UNIT=*, FMT=*) 'Hello World'
      END
Prints "Hello World" onto the screen.


 Squares   Fortran 77   Michael Neumann
      PROGRAM SQUARE
      DO 15,I = 1,10
        WRITE(*, *) I*I
15    CONTINUE
      END
Outputs the squares from 1 to 10.


 Hello World   Fortran 90   Michael Neumann
PROGRAM HelloWorld
   PRINT *, "Hello World"
END PROGRAM HelloWorld
Prints "Hello World" onto the screen.


 Matrix Multiplication   Fortran 90   Michael Neumann
program TestMatrixMult

  real, dimension( 3, 3 ) :: A, B, C

  ! create identity matrix 
  A = 0.0; do i = 1, size(A); A(i,i) = 1.0; end do


  ! initialize matrix randomly
  call random_number( B )

  ! multiply matrices A and B
  C = matrixMult( A, B )

  ! output the three matrices
  print *, A, B, C

contains

!
! Alternatively use built-in function 'matmul' 
! (another built-in is 'dot_product') 
!
function matrixMult( A, B ) result ( C )

  implicit none

  real, dimension( :, : ), intent( in )     :: A  ! m x n
  real, dimension( :, : ), intent( in )     :: B  ! n x p
  real, dimension( size(A, 1), size(B, 2) ) :: C  ! m x p

  integer i, j

  do i = 1, size(C, 1)
    do j = 1, size (C, 2)
      C(i, j) = sum( A(i, :) * B(:, j) )
    end do
  end do

end function matrixMult

end program TestMatrixMult







 FOX    up
 
 


 Hello World   Pablo Romero
? "Hello World"
return
Prints "Hello World" onto the screen.






 Gofer    up
  similar languages: ML   Haskell   Hope   Objective Caml   Miranda  
  Description: Gofer is a functional Haskell-like language.


 Ackermann   Michael Neumann
ackermann 0 n = n + 1
ackermann m 0 = ackermann (m-1) 1
ackermann m n = ackermann (m-1) (ackermann m (n-1))



 ADT Stack   Michael Neumann
data Keller a = Create | Push (Keller a) a

pop   :: Keller a -> Keller a
top   :: Keller a -> a
empty :: Keller a -> Bool

empty (Create) = True
empty (Push k x) = False
pop (Push k x) = k
top (Push k x) = x

--------------------------------------------

f1 = top(Push (Create) 3)
f2 = top(Push (Push (Create) 3) 4)
f3 = empty(pop(Push (Push (Create) 3) 4))
f4 = Push (pop(Push (Push (Create) 3) 5)) 2
f5 = pop(Push (pop(Push (Push (Create) 3) 4)) 2)
Implementation of the ADT (abstract datatype) Stack.


  Factorial   Michael Neumann
--
-- Fakultaet in Gofer
--

fac :: Int -> Int
fac 0 = 1
fac n = n * fac(n-1)


-- Im Gofer-Interpreter folgendes eingeben: fac 6
Calculates the factorial. Results 720.


 gcd   Michael Neumann
ggt :: Int -> Int -> Int

ggt p q =  if p `rem` q /= 0 then
             ggt q (p `rem` q)
           else
             q
Greatest common divisor


 Hello World   Michael Neumann
show "Hello World"
Prints "Hello World" onto the screen.


  Length of a list   Michael Neumann
len []    = 0
len (h:t) = len t + 1
Determines the length of a list.


 MergeSort   Michael Neumann
mmerge :: [Int] -> [Int] -> [Int]

mmerge []  []  = []
mmerge a   []  = a
mmerge []  b   = b
mmerge (ha:ta) (hb:tb) = if ha < hb then
                           [ha] ++ mmerge ta (hb:tb)
                         else
                           [hb] ++ mmerge (ha:ta) tb


mergesort :: [Int] -> [Int]

mergesort [] = []
mergesort l  = if length l == 1 then l
               else
                 mmerge (mergesort (drop n l))
                        (mergesort (take n l))
                 where n = length l / 2
MergeSort






 Haskell    up http://www.haskell.org
  similar languages: ML   Gofer   Hope   Objective Caml   Miranda  
  Description: Haskell is a pure lazy functional programming language:
  • lazy evaluation: infinite (e.g. "ones = 1:ones" is possible), cyclic datastructures; excution only when needed; non strict functions
  • polymorph: polymorphic functions (e.g. many list operations); overloading (ad hoc polymorhism), e.g. + is defined on several datatypes (other functional languages have for that different operators, e.g. Ocaml has + for Integers and +. for Floats)
  • No semicolons needed: layout driven (but possible to use explicit semicolons and braces)


  Factorial (1)   Michael Neumann
fac 0 = 1
fac n = n * fac (n-1)


-- type "fac 6" to calculate the result 
Calculates the factorial. Results 720.


  Factorial (2)   Michael Neumann
fac n
  | n == 0    = 1
  | otherwise = n * fac (n-1)


-- type "fac 6" to calculate the result 
Calculates the factorial. Results 720.


 Fibonacci   Mirko Rahn
-- ersten zwanzig Fibonacci-Zahlen
-- by Mirko Rahn <mai99dla@studserv.uni-leipzig.de>

module Main where

fibs = 1 : 1 : zipWith (+) fibs (tail fibs)

main = print $ take 20 fibs

-- Ausgabe:
-- [1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765]
Outputs the first 20 fibonacci numbers.


 HaXml Demo Application   Michael Neumann
{-
  Demo Application using HaXml 1.02
  Copyright (c) 2001 by Michael Neumann
  $Id: haxml-demo.hs,v 1.1 2001/10/17 22:41:17 michael Exp $

  HaXml: http://www.cs.york.ac.uk/fp/HaXml
  Compile with: hmake -nhc98 haxml-demo
  For sample XML file, see below.
-}
module Main where
import XmlLib
import XmlCombinators

main = processXMLwith
   ( mkElem "HTML"
      [ mkElem "BODY"
         [ message `o` (tag "messages" /> tag "message") ]
      ]
   )

message =
   mkElem "DIV"
   [
   -- Message Title
   mkElem "DIV"
      [ mkElem "B"
         [ ("["!) , tag "message" /> tag "category" /> txt , ("] "!) ]
      , mkElem "EM"
         [ txt `o` children `o` tag "title" `o` children `o` tag "message" ]
      , literal " at "
      , tag "message" /> tag "date" /> txt
      , literal " sent by "
      , tag "message" /> tag "author"
         ?> mkElemAttr "A"
            [ ("HREF", (tag "message" /> tag "author" /> tag "email" /> txt) ) ]
            [ tag "message" /> tag "author" /> tag "name" /> txt ]
         :> literal "Unknown Person"
      ]
   ,
   -- Message Body
   mkElem "DIV"
      [ keep `o` (tag "message" /> tag "text") ]
   ,
   mkElem "BR" []
   ]

{- Sample XML file follows:
<?xml version="1.0"?>
<messages>
  <message id="1">
    <date>2001-12-31</date>
    <category>Admin</category>
    <title>CVS Updated</title>
    <text>CVS has been updated.</text>
  </message>

  <message id="2">
    <author>
      <name>Michael</name>
      <email>mneumann@ntecs.de</email>
    </author>
    <date>2001-12-30</date>
    <category>Programming</category>
    <title>New function</title>
    <text>New method <font color="red">set_parser</font> in module XXX.</text>
  </message>
</messages>
-}
Transforms a XML document.


 Hello World   Michael Neumann
module HelloWorld (main) where

main = putStr "Hello World\n"
Prints "Hello World" onto the screen.


 InsertionSort   Michael Neumann
module InsertionSort (insertionSort) where

import List (insert)

insertionSort :: Ord a => [a] -> [a]
insertionSort = foldl (\ a b -> insert b a) []
Sortieren durch Einfuegen


 InsertionSort (2)   Michael Neumann
module InsertionSort (insertionSort) where

-- insert is already defined in module List of Haskell 98
insert e [] = [e]
insert e lst@(x:xs)
  | e < x     = e : lst
  | otherwise = x : (insert e xs)

insertionSort lst = insertionSort' lst [] where
  insertionSort' [] lst = lst
  insertionSort' (x:xs) lst = insertionSort' xs (insert x lst)
Sortieren durch Einfuegen


 Quicksort   Michael Neumann
quicksort [] = []
quicksort (s:xs) = quicksort [x|x <- xs,x < s] ++ [s] ++ quicksort [x|x <- xs,x >= s] 
Quicksort sorting algorithm


 Squares (1)   Michael Neumann
--
-- written in Haskell 1.4 (Hugs 1.4 for Windows)
-- by Michael Neumann
--

module Squares (main) where

square :: [Int] -> String
square []    = "\n"
square (h:t) = show (h*h) ++ " " ++ square t

main = putStr (square [1..10])
Outputs the squares from 1 to 10.


 Squares (2)   Matthias Mann
--
-- von Matthias Mann
--

module Squares (main) where

import List

main =
   putStr . concat . intersperse " " . map (show . (^2))) [1..10]
Outputs the squares from 1 to 10.


 Squares (3)   Michael Neumann
-- construct a conceptual infinite list of numbers starting at 1
numbersFrom n = n : numbersFrom (n+1)   

-- conceptual infinite list of square numbers starting at 1
squares = map (^2) (numbersFrom 1)

-- take the first 10 square numbers
take 10 squares
Outputs the squares from 1 to 10.


 Squares (4)   Mirko Rahn
-- ersten zehn Quadrate
-- by Mirko Rahn <mai99dla@studserv.uni-leipzig.de>

module Main where

squares n m = [ i^2 | i <- [n..m] ]

main = print $ squares 1 10

-- Ausgabe: [1,4,9,16,25,36,49,64,81,100]
Outputs the squares from 1 to 10.


 Hello World   Glasgow Haskell Compiler (GHC)   Michael Neumann
-- file: Main.hs
-- compile: ghc --make Main -o main

module Main (main) where

main = putStr "Hello World\n"
Prints "Hello World" onto the screen.






 HB (Hyper Builder)    up http://bachue.com/hb
 
  Description: Hyper Builder (HB) is a language, which lets you easily create dynamic Websites. You can create your own HTML-tags, which are then substituted by self-defined blocks. Within a HB-page you can mark blocks, which could then be showed and are accessible through an URL from a webbrowser. So you can easily put HTML-pages which belong together into one HB-file. They could then separately shown as own HTML-pages. There exist pre-defined tags for following application-domains: Authentification, SQL-Queries (MySQL, PostgreSQL), polls, counter, emails, cookies... Altogether, in comparision to other languages like XML/XSL, PHP or Perl, a very easy-to-use language (also for designer) but which is therefore NOT less powerful.


 Hello World   Michael Neumann
# definiere ein Objekt HelloWorld
:set HelloWorld
<b>HelloWorld</b>
:


# definiert das Startobjekt, welches man mittels URL aufrufen kann
:out main
<html><head></head><body>
<HelloWorld>   <!-- ruft das Objekt HelloWorld auf -->
</body></html>
:
Shows "Hello World" in the webbrowser.


  Simple HTML-form   Michael Neumann
:set page
<html>
<head><title>Einfaches HTML-Formular</title></head>
<body>
:

:set /page
</body></html>
:



# definiert das Formular
:set formular.show
<form action="formular.send">
Anrede: 
<input type="radio" name="Anrede" value="Herr"> Herr 
<input type="radio" name="Anrede" value="Frau" checked> Frau
<br><br>
Ihr Name: <input type=text name="Name">
<input type=submit value="Senden">
</form>
:

# wird aufgerufen, wenn das Formular abgesendet wird
# "hb.cgi" liest die vom Formular übergebenen Parameter
:out formular.send
<page>
Hallo <hb.cgi name="Anrede"> <hb.cgi name="Name">!
<br><hr>
<formular.show>
<br>
<a href="main">Start</a>
</page>
:


# wird ganz am Anfang aufgerufen
:out main
<page>
<formular.show>
</page>
:
Shows a formular in the webbroswer, wherby you were asked for the name and title. If you send the formular, you'll be greeted with "Hallo Herr/Frau X" (in English: Hello Mr./Mrs. X). Below that, the formular is shown.






 Hope    up
  similar languages: ML   Haskell   Gofer   Objective Caml   Miranda  
 


 Hello World   Michael Neumann
"Hello World\n";
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
! gibt die Quadrate von 1 bis 10 aus

dec squares : num -> list(num);
--- squares 0 <= nil;
--- squares x <= squares(x-1) <> [x*x];

squares 10;
Outputs the squares from 1 to 10.






 HPGL    up
 
  Description: HPGL - Hewlett-Packard Graphics Language. On certain machines (Laser printers), it may be necesary to issue the escape sequence ESC%1B to enter HPGL mode. ESC%1A will exit HPGL mode if you used the above escape sequence.


 Hello World   Jay Keck
IN1;            CO "Initialization string, restores defaults";
PA 0,0;         CO "Absolute positioning at 0,0";
PR 1000,1000;   CO "Relative postitioning - x+=1000 plu, y+=1000plu";

                CO "1 mm = 40 PLU";

DT 1,*;         CO "Use * as a label delimeter, and don't print it";
SP1;            CO "Select Pen 1 (black)";
PD;             CO "Pen down (like logo)";

LBHello world!*;

PU;             CO "Pen up";
PA0,0;          CO "Back to the origin";
SP0;            CO "Select Pen 0 (All done)";
Prints "Hello World" onto the screen.






 HTML    up
  similar languages: SGML   WML (Wireless Markup Language)   XHTML   XML  
 


 Hello World   Michael Neumann
<!-- Hello World in HTML -->

<html>
<head>
   <title>Hello World</title>
</head>
<body>
   Hello World
</body>
</html>
Prints "Hello World" onto the screen.






 IBM EXEC    up
 
 


 Hello World   IBM EXEC (VM/CMS)   B. Bora Bali
&CONTROL
*
&TYPE Hello World!
*
&EXIT 0
Prints "Hello World" onto the screen.


 Hello World   IBM EXEC2 (VM/CMS)   B. Bora Bali
&TRACE OFF
*
&TYPE Hello World!
*
&EXIT 0
Prints "Hello World" onto the screen.






 Icon    up
 
 


 Hello World   Michael Neumann
procedure main(args)
   write("Hello World\n")
end
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
# gibt die Quadrate von 1 bis 10 aus

procedure main(args)
   every i := 1 to 10 do {
      write(i*i, " ")
   }
end
Outputs the squares from 1 to 10.






 J    up
  similar languages: A+   APL   K  
 


 Eulersche Number (1)   Michael Neumann
+/ % ! i. 9
Calculates the eulersche-number (e=2.71828).


 Eulersche Number (2)   Martin Neitzel
1x1
Calculates the eulersche-number (e=2.71828).


 Hello World   Michael Neumann
'Hello World'
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
a =. 1 + i. 10
a * a
Outputs the squares from 1 to 10.


 Squares (2)   Javier Gamero
*:>:i.10
Outputs the squares from 1 to 10.






 Java    up
  similar languages: C   C#   C++   C-Talk   D   Cilk   Objective-C   Pike   TOM  
 


 Hello World (Applet)   Michael Neumann
import java.applet.*;
import java.awt.*;

public class HelloWorld extends Applet {
   public void paint(Graphics g) {
      g.drawString("Hello World",10,10);
   }
}
Prints "Hello World" onto the screen.


 Hello World (Application)   Michael Neumann
public class HelloWorld {
   public static void main(String[] args) {
      System.out.println("Hello World");
   }
}
Prints "Hello World" onto the screen.


 Hello World (Servlet)   Michael Neumann
/*
 * Hello World in Java (Servlet)
 */ 

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet
{
  public void doGet (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
  {
    PrintWriter out;
    String text = "Hello World in Java (Servlet)";
    
    response.setContentType("text/html");
    out = response.getWriter();
            
    out.println("<html><head><title>");
    out.println(text);
    out.println("</title></head><body>");
    out.println(text);
    out.println("</body></html>");

    out.close();
  }
}
Prints "Hello World" onto the screen.


 Hello World (Swing-GUI)   Michael Neumann
import javax.swing.*;

class HelloWorldSwing {

  public static void main(String args[]) {
    JFrame mainWin = new JFrame("MainWindow");
    JButton button = new JButton("Hello World");
    mainWin.getContentPane().add(button);
    mainWin.pack();
    mainWin.show();
  }

}
Prints "Hello World" onto the screen.


 Multi-threading   Michael Neumann
public class ThreadTest implements Runnable {
  public static void main(String args[]) {
    int i, j;

    // create 1000 threads
    for (i=0; i<=1000; i++) {
      Thread th = new Thread(new ThreadTest());
      th.start();
    }

    // do some calculation
    for(i=j=0; i<=100000; i++) {
      j = j + i;
    }
  }

  public void run() {
    try {
      // sleep forever
      Thread.currentThread().sleep(1000000);
    } catch (InterruptedException e) {}
  }
}
Create 1000 threads that sleep.






 JavaScript    up
 
 


 Hello World (1)   Michael Neumann
<html>
<body onload="onload()">
<script language="JavaScript">
<!--

// JavaScipt in einer HTML-Seite eingebettet

function onload() {
   document.writeln('Hello World');
}

//-->
</script>
</body>
</html>
Prints "Hello World" onto the screen.


 Hello World (2)   Gary Haran
<html>
  <head>
    <title>Javascript Hello World</title>
  </head>
  <body>

    <script>
       document.write("Hello World!");
    </script>

  </body>
</html>
Prints "Hello World" onto the screen.


 Squares   Gary Haran
<html>
  <head>
    <title>Javascript Squares</title>
  </head>
  <body>

    <script>
      for (var i = 1; i <= 10; ++i)
      {
        document.write( Math.pow(i, i) + "<br>" );
      }
    </script>

  </body>
</html>
Outputs the squares from 1 to 10.






 Jovial    up http://www.bath.ac.uk/~cs1lomp/jovial/index.php
 
  Description: Jovial is Jules' own version of IAL (international algorithmic language). It's similar to ALGOL 60 and was mainly used by the US Air Force.






 K    up http://www.kx.com
  similar languages: A+   APL   J  
 


 Eulersche Number   Michael Neumann
/ die Eulersche Zahl ist die Summe der Reziproken der Fakultäten

fac:{*/1+!x}         / Fakultät-Funktion

+/ % fac' ! 10       / fac' wendet die Funktion auf eine Liste an (EACH)
Calculates the eulersche-number (e=2.71828).


  Factorial (iterative)   Michael Neumann
fac:{ */ 1 + !x }    / { ... } ist eine Fuktion

fac @ 6              / Funktion aufrufen mit 6 als Parameter
Calculates the factorial. Results 720.


  Factorial (recursive)   Michael Neumann
fac: {
   if[ x>1; : x * fac[x-1] ]   / wenn x>1, x * fac(x-1) zurückgeben
   :1                          / ansonsten 1 zurückgeben
}

/ oder kürzer:
fac: {:[x>1; x * fac[x-1]; 1]}

/ oder ohne den Funktionsnamen zu verwenden:
fac: {:[x>1; x * _f[x-1]; 1]}


fac . 6        / Funktion aufrufen mit 6 als Parameter
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
/ Hello World in K

` 0:"Hello World\n"
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
i:1 + !10
`0:5:i*i
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
i:1 + !10   / erzeugt liste von 1-10 und weist diese 'i' zu

`0:5:i*i    / `0:x gibt x auf Bildschirm aus
            / 5:x wandelt x in String
Outputs the squares from 1 to 10.






 Labview    up
 
  Description: Labview is a visual programming tool.


 Complex Example   Norbert Silberhorn

This screenshot shows a complex program in Labview.






 LaTeX    up
 
 


  Factorial   Mirko Rahn
% Fakultät by Mirko Rahn <mai99dla@studserv.uni-leipzig.de>

\documentclass{article}

\usepackage{ifthen}

\newcounter{multi} \newcounter{multa}

% berechnet #1 * #2 in multa
\newcommand{\mult}[2]{ \setcounter{multi}{1} \setcounter{multa}{#1}
 \whiledo{\themulti < #2}{ \addtocounter{multa}{#1} \stepcounter{multi} }
}

\newcounter{faki} \newcounter{faka}

% berechnet #1!
\newcommand{\fac}[1]{
 \setcounter{faka}{1} \setcounter{faki}{2}
 \whiledo{\thefaki < #1}{ \mult{\thefaka}{\thefaki}
                          \setcounter{faka}{\themulta}
                          \stepcounter{faki}
                        }
 \mult{\thefaka}{\thefaki} \themulta
}

\begin{document}

$6!=\fac{6}$

\end{document}

% Ausgabe: 6!=720
Calculates the factorial. Results 720.


 Fibonacci   Mirko Rahn
% ersten zwanzig Fibonacci-Zahlen
% by Mirko Rahn <mai99dla@studserv.uni-leipzig.de>

\documentclass{article}

\usepackage{ifthen}

\newcounter{fiba} \newcounter{fibb} \newcounter{fibc} \newcounter{fibrun}

% fib{k} gibt die k-te Fibonaccizahl F_k
\newcommand{\fib}[1]{
 \init \whiledo{\thefibrun < #1}{ \step \stepcounter{fibrun} } \thefiba
}
\newcommand{\init}{
 \setcounter{fiba}{1}\setcounter{fibb}{1}\setcounter{fibrun}{0}
}
\newcommand{\step}{\add \rotate}
\newcommand{\add}{\setcounter{fibc}{\thefiba}\addtocounter{fibc}{\thefibb}}
\newcommand{\rotate}{\setcounter{fiba}{\thefibb}\setcounter{fibb}{\thefibc}}

\begin{document}

\newcounter{i} \newcounter{en} \setcounter{en}{20}
Die ersten \theen\ Fibonacci-Zahlen lauten:\\
\whiledo{\thei < \theen}{$\fib{\thei}$ \stepcounter{i}}

\end{document}

% Ausgabe: Die ersten 20 Fibonacci-Zahlen lauten:
%          1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765
Outputs the first 20 fibonacci numbers.


 Hello World   Michael Neumann
% Hello World in LaTeX

\documentclass[a4paper]{report}
\title{Hello World in LaTeX}
\begin{document}
Hello World
\end{document}
Prints "Hello World" onto the screen.


 Squares   Mirko Rahn
% ersten zehn Quadrate
% by Mirko Rahn <mai99dla@studserv.uni-leipzig.de>

\documentclass{article}

\usepackage{ifthen}

\newcounter{multi} \newcounter{multa}

% berechnet #1 * #2
\newcommand{\mult}[2]{
 \setcounter{multi}{1} \setcounter{multa}{#1}
 \whiledo{\themulti < #2}{ \addtocounter{multa}{#1} \stepcounter{multi} }
 \themulta
}

\begin{document}

\newcounter{i} \newcounter{en} \setcounter{i}{1} \setcounter{en}{10}
Die ersten \theen\ Quadrate lauten: \stepcounter{en}
\whiledo{\thei < \theen}{$\mult{\thei}{\thei}$ \stepcounter{i}}

\end{document}

% Ausgabe: Die ersten 10 Quadrate lauten: 1 4 9 16 25 36 49 64 81 100
Outputs the squares from 1 to 10.






 Leda    up
  similar languages: Modula   Oberon   Obliq   Pascal   Phantom   PL/0   PL/0E   YAFL  
 


 Hello World   Michael Neumann
{ Hello World in Leda }

include "std.led";

begin
   print("Hello World");
end;
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
include "std.led";

var i:integer;

begin
   for i:=1 to 10 do
   begin
      print("" + i*i + " ");
   end;
end;
Outputs the squares from 1 to 10.






 LIRL    up
 
  Description: Daniel Foesch <dfoesch@cs.nmsu.edu>: LIRL, "List Implicit Recursive Language" appears to be very similar to functional languages, but rather than everything being functions, everything is variables (a function is just an array of expressions executed in a particular order). There is no distinction given between functions, variables and arrays, except how they are used. It also oddly enough, has both lazy and eager evaluation, under particular circumstances. Something very interesting indeed... It could also be akined to LISP since it works on lists in a very similar way to the whole LISP/Scheme family, except that the lists are generally implicitly determined, and are extented or shortened by various operators. The only time explicit list construction is done is when you need a list within a list, where there is no operator.


  Factorial   Daniel Foesch
sub fac 1,
  if == 1 @[0]
    1,
  ( * @[0] &fac -- @[0] ),
Calculates the factorial. Results 720.


 Fibonacci Sequence   Daniel Foesch
sub fib 1,
  if <= 1 @[0]
    1,
    &fib -- @[0] & fib - @[0] 2



 Hello World   Daniel Foesch
print "Hello World"
Prints "Hello World" onto the screen.






 Lisp    up
  similar languages: Scheme  
 


 Hello World   Michael Neumann
(print "Hello World")
Prints "Hello World" onto the screen.


  Factorial (iterative)   Common Lisp   Marco Baringer
(defun fact (n)
  (loop for i from 2 to n
        for fact = 1 then (* fact i)
        finally (return fact)))

(format t "Factorial of 6 is: ~A~%" (fact 6))
Calculates the factorial. Results 720.


  Factorial (recursive)   Common Lisp   Marco Baringer
(defun fact (n)
  (if (zerop n)
     1
     (* n (fact (1- n)))))

(format t "Factorial of 6 is: ~A~%" (fact 6))
Calculates the factorial. Results 720.


 Hello World   Common Lisp   Marco Baringer
(write-line "Hello World!")
Prints "Hello World" onto the screen.


 OO - Shape, Circle, Rectangle   Common Lisp   Marco Baringer
;; define the various classes

(defclass shape ()
  ((pos-x :type real
          :accessor pos-x)
   (pos-y :type real
          :accessor pos-y))
  (:documentation "A generic shape in a 2 dimensial plane"))

(defclass rectangle (shape)
  ((width :type real
          :accessor width)
   (height :type real
           :accessor height))
  (:documentation "A rectangle"))

(defclass cirle (shape)
  ((radius :type real
           :accessor x-radius))
  (:documentation "An cirlce"))

;; define the methods

(defmethod move-to ((thing shape) new-x new-y)
  "Move the shape THING to the new position (new-x, new-y)"
  (setf (pos-x thing) new-x
        (pos-y thing) new-y))

(defmethod shift-to ((thing shape) delta-x delta-y)
  "Move the shape THING by (delta-x, delta-y)"
  (incf (pos-x thing) delta-x)
  (incf (pos-y thing) delta-y))

(defmethod scale ((rec rectangle) factor)
  "Scale the rectangle REC by factor"
  (with-slots (width height) rec
    (setf width (* factor width)
          height (* factor height))))

(defmethod scale ((cir circle) factor)
  "Scale the circle CIR by factor"
  (setf (radius cir) (* (radius cir) factor)))



 Squares (1)   Common Lisp   Friedrich Dominicus
(defun print-squares (upto)
  ( loop for i from 1 to upto
         do (format t "~A^2 = ~A~%" i (* i i))))
Outputs the squares from 1 to 10.


 Squares (2)   Common Lisp   Marco Baringer
(dotimes (i 10)
  (format t "~D " (expt i 2)))
Outputs the squares from 1 to 10.


 Squares (3)   Common Lisp   Marco Baringer
(loop for i from 1 upto 10
      for i^2 = (expt i 2)
      do (format t "~D " i^2))
Outputs the squares from 1 to 10.


 Squares   Emacs Lisp   Michael Neumann
(let ( (a 1) )
  (while (<= a 10)
    (princ (* a a)) (princ " ")
    (setq a (+ a 1))
  )
)
Outputs the squares from 1 to 10.






 Logo    up
 
 


 Hello World   Michael Neumann
print [Hello World]
Prints "Hello World" onto the screen.






 Lout    up
 
 


 Hello World   Michael Neumann
@SysInclude {doc}
@Doc @Text @Begin
Hello World
@End @Text
Prints "Hello World" onto the screen.






 Lua    up http://www.tecgraf.puc-rio.br/lua/
 
  Description: "Lua is a powerful, light-weight programming language designed for extending applications. Lua is also frequently used as a general-purpose, stand-alone language." "Lua combines simple procedural syntax (similar to Pascal) with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, interpreted from bytecodes, and has automatic memory management, making it ideal for configuration, scripting, and rapid prototyping." Lua has a very small footprint and let's itself very easy embed into other languages.


  Factorial   Michael Neumann
function fac(n)
  if n < 2 then
    return 1
  else
    return n * fac(n-1)
  end
end

print(fac(6))
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
-- Hello World in Lua

print("Hello World\n")
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
-- for var = from, to [, step] do block end
for i = 1, 10, 1 do
  print(i*i)
end
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
function range(from, to)
  arr, inx = {}, 0
  for i = from, to do
    arr[inx] = i
    inx = inx + 1
  end
  return arr
end

for index, value in range(1, 10) do
  print(index .. "^2 = " .. value)
end
Outputs the squares from 1 to 10.






 Make    up
 
 


 Hello World   Michael Neumann
#
# Hello World in Make
#

main-target: 
    @echo "Hello World"
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
RANGE=1 2 3 4 5 6 7 8 9 10

main:
    @for i in ${RANGE}; do \
        echo `expr $$i \* $$i`; \
    done
Outputs the squares from 1 to 10.






 Mercury    up http://www.cs.mu.oz.au/research/mercury/
 
  Description: From Mercurys homepage: "Mercury is a new logic/functional programming language, which combines the clarity and expressiveness of declarative programming with advanced static analysis and error detection features. Its highly optimized execution algorithm delivers efficiency far in excess of existing logic programming systems, and close to conventional programming systems. Mercury addresses the problems of large-scale program development, allowing modularity, separate compilation, and numerous optimization/time trade-offs."


  Factorial   Michael Neumann
:- module factorial.

:- interface.

:- pred factorial(int::in, int::out) is det.

:- implementation.

:- import_module int.

factorial(N, R) :-
        ( if N =< 1 then
                        R = 1
        else
                        factorial(N - 1, R0),
                        R = N * R0
         ).



 Hello World   Michael Neumann
% Hello World in Mercury
%
% compile with:
%   mmake hello.depend
%   mmake hello

:- module hello.
:- interface.
:- import_module io.

% di=desctructive input, uo=unique output
:- pred main(io__state::di, io__state::uo) is det.

:- implementation.

% "-->" tells that we are using DCG (definite clause grammar), which frees us
% from threading some extra arguments through the code.
main --> io__write_string("Hello World\n").
Prints "Hello World" onto the screen.


  Length of a list   Michael Neumann
%
% Calculates the length of a list
%

:- import_module list, int.

:- pred length(list(T)::in, int::out) is det.

length(L, N) :-
        (
                % if L is empty
                L = [],
                N = 0
        ;
                % else 
                L = [_Hd | Tl],
                length(Tl, N0),
                N = N0 + 1
        ).
Determines the length of a list.






 merd    up http://merd.sf.net
 
  Description: From merd's homepage:
merd is a language inspired (mainly) by Caml, O'Haskell and Ruby. It also has many features of Dylan.

Features:

  • function/method calling
    • parametric and ad'hoc polymorphism (overloading/refining/specializing)
    • late binding
    • default parameters
  • types
    • strongly typed
    • static typing (keeping expressivity!)
    • type inference (see ML, and more precise O'Haskell)
    • subtyping (extendable structs, extendable datatype, subranges...)
    • abstract-types (mix-in's, aka type-classes)
    • types as first-class citizen
  • functional programming
    • functions as first-class citizen (even overloaded one)
    • anonymous functions
    • partial application (currying)
  • sugaring
    • user definable operators (infix, prefix, suffix, multi-op, around-op)
    • OO-like syntax (purely syntactic)
    • indentation based grouping (see Haskell&Python), also called layout
    • horizontal layout: 1+2 * 3 is (1+2) * 3 (merd innovation!)
    • pattern-matching (see ML)
    • macros (?)
  • extensible powerful library


All in all, sounds like a really interesting languge, even if not yet an interpreter is available.


  Factorial   Pixel
# Three factorial functions

fact :=
    0 -> 1
    n -> n * fact(n-1)

fact'(n) := if n == 0 then 1 else n * fact'(n-1)

fact''(n) :=
    fact = 1
    while n >= 0 do
        fact *= n
        n--
    fact
Calculates the factorial. Results 720.


 Hello World   Pixel
# Hello World in merd

"Hello World!".println
Prints "Hello World" onto the screen.


 Squares (1)   Pixel
println(
    1..10.map(n -> "{n ** 2}").join(" ")
)
Outputs the squares from 1 to 10.


 Squares (2)   Pixel
1..10.map(** 2 ~ to_string).join(" ").println
Outputs the squares from 1 to 10.






 Miranda    up
  similar languages: ML   Haskell   Gofer   Hope   Objective Caml  
 


  Factorial (1)   Michael Neumann
fac 0 = 1
fac 1 = 1
fac n = n * fac (n-1) 
Calculates the factorial. Results 720.


  Factorial (2)   Michael Neumann
fac n = n * fac (n-1),  if n >= 2 
      = 1,              if n < 2 
Calculates the factorial. Results 720.


 gcd   Martin Guy
  gcd a b = gcd (a-b) b,  if a>b
          = gcd a (b-a),  if a<b
          = a,            if a=b
Greatest common divisor


 Hello World   Martin Guy
"Hello World!"
Prints "Hello World" onto the screen.


 Quicksort   Martin Guy
qsort []    = []
qsort (a:x) = qsort [ b | b <- x; b<=a ]
              ++ [a] ++
              qsort [ b | b <- x; b>a ]
Quicksort sorting algorithm


 Squares (1)   Martin Guy
map (^2) [1..10]
Outputs the squares from 1 to 10.


 Squares (2)   Martin Guy
[ n*n | n <- [1..10] ]
Outputs the squares from 1 to 10.






 Moby    up http://moby.cs.uchicago.edu/
 
  Description: From Moby's homepage:

Moby is an experiment in language design and implementation. Our goal is to combine support for class-based object-oriented programming and higher-order concurrency with the desirable features of ML-like languages: advanced module systems, parametric polymorphism, inductive datatypes, pattern matching, and first-class functions. The Moby project started out as a testbed for the design of ML2000.

Features:
  • Modules: Moby has an ML-style module system with opaque signature matching. Definitional specifications are used instead of sharing constraints.
  • Polymorphism: Moby supports parametric polymorphism with explicit quantification (including bounded quantification). Because function types are explicit in the syntax, polymorphic recursion is supported.
  • Subtyping: Moby supports structural subtyping on object types and by-name subtyping on tagtypes and class types. Subtyping is extended to other type constructors in the standard ways.
  • Objects: Moby supports objects with self-application semantics. An object type specifies the interface of an object, but not its implementation.
  • Classes: Moby supports object creation via classes. Unlike the more complicated class mechanisms of Java and C++, Moby's class mechanism only supports those mechanisms that are intrinsic to classes. We rely on the module system to support namespace management and visibility control.
  • Concurrency: Moby supports CML-style higher-order concurrency.
  • Data constructors: Moby supports a variety of mechanisms for defining data constructors, including ML-style datatypes, extensible tagtypes, and abstract value constructors.
  • Pattern matching: Moby supports ML-style pattern matching for control-flow and data deconstruction.




 Hello World   Michael Neumann
// Hello World in Moby
module Main {
  val () = ConsoleIO.print "Hello World\n"
}
Prints "Hello World" onto the screen.






 Modula    up
  similar languages: Oberon   Obliq   Leda   Pascal   Phantom   PL/0   PL/0E   YAFL  
 


 Hello World   Modula-2   Michael Neumann
(* Hello World! *)

MODULE HelloWorld;

FROM InOut IMPORT WriteString, WriteLn;

BEGIN
   WriteString('Hello World');
   WriteLn;
END HelloWorld.
Prints "Hello World" onto the screen.


 Hello World   Modula-3   Michael Neumann
(* Hello World! *)

MODULE HelloWorld EXPORTS Main;

IMPORT SIO;

BEGIN
   SIO.PutText("Hello World\n");
END HelloWorld.
Prints "Hello World" onto the screen.


 Squares   Modula-3   Michael Neumann
MODULE Squares EXPORTS Main;

IMPORT SIO;

BEGIN
   FOR i:=1 TO 10 DO
      SIO.PutInt(i*i);
      SIO.PutText(" ");
   END;
END Squares.
Outputs the squares from 1 to 10.






 mpC    up http://www.ispras.ru/~mpc
 
  Description: mpC is an extension of ANSI C for parallel computing features.






 MUMPS    up
  similar languages: Caché ObjectScript  
  Description: MUMPS (also known as M) stands for "Massachusetts general hospital Utility MultiPurpose System". Intersystems Caché is MUMPS compatible!


 Hello World (1)   Connel MacKenzie
HELLO   W "Hello World",!
        Q
Prints "Hello World" onto the screen.


 Hello World (2)   Connel MacKenzie
HELLO   ; C. MacKenzie ; 3/30/2001 ; "Hello World" routine
        WRITE "Hello World",!
        QUIT
Prints "Hello World" onto the screen.


 Hello World (interpreted mode)   Connel MacKenzie
>W "Hello World",!
Prints "Hello World" onto the screen.


 Sorting   Connel MacKenzie
SORT    ; C. MacKenzie ; 3/30/2001 ; print out array X sorted
        ZWRITE X
        QUIT


; Invoking from interpreted mode:
>KILL  SET X("Hello")=" World?",X("WORLD")="Hi there." DO ^SORT
; result:
;   X("Hello")=" World?"
;   X("WORLD")="Hi there."

; Other example:
>S X("Hello","World")="" ZW X
; result:
;   X("Hello","World")=""

Prints out an array sorted.


 Squares (1)   Connel MacKenzie
SQUARES F I=1:1:10 W I*I," "
        W !
        Q
Outputs the squares from 1 to 10.


 Squares (2)   Connel MacKenzie
SQUARES ; C. MacKenzie ; 3/30/2001 ; output squares from 1 to 10
        FOR I=1:1:10 WRITE I*I," "
        WRITE !
        QUIT
Outputs the squares from 1 to 10.


 Squares (interpreted mode)   Connel MacKenzie
>F I=1:1:10 W I*I," "
Outputs the squares from 1 to 10.






 NESL    up
 
 


 Hello World   Michael Neumann
% Hello World %

print_string("Hello World\n");
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
function pt(x) = print_string( @(a*a) ++ " " );

{ pt(a) : a in [1..11] };
Outputs the squares from 1 to 10.






 Oberon    up
  similar languages: Modula   Obliq   Leda   Pascal   Phantom   PL/0   PL/0E   YAFL  
 


 Hello World   Michael Neumann
MODULE HelloWorld;

IMPORT Out;

BEGIN
   Out.Open;
   Out.String('Hello World');
END HelloWorld.
Prints "Hello World" onto the screen.






 Objective-C    up
  similar languages: C   C#   C++   C-Talk   D   Cilk   Java   Pike   TOM  
 


 Hello World (1)   Michael Neumann
void main()
{
   printf("Hello World\n");
}
Prints "Hello World" onto the screen.


 Hello World (2)   Michael Neumann
#import "objc/Object.h"

//
//  Compile with:
//
//    cc hw.m -o hw -lobjc -lm
//

@interface HelloWorld : Object
{
  STR msg;                 // Instance Variable
}

+ new;                     // Class/Factory method
- print;                   // Instance method
- setMessage: (STR) m;     //  "         "

@end

@implementation HelloWorld

+ new
{
  self = [super new];
  msg = "";
  return self;
}

- print
{
  printf("%s\n", msg);
  return self;
}

- setMessage: (STR) m
{
  msg = m;
  return self;
}

@end


int main(int argc, char**argv) {
  id obj;

  obj = [HelloWorld new];

  [[obj setMessage: "Hello World"] print];

  return 0;
}
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
void main()
{
   int i;
   
   for(i = 1; i <= 10; i++) printf("%d ", i*i);
}
Outputs the squares from 1 to 10.






 Objective Caml    up http://caml.inria.fr
  similar languages: ML   Haskell   Gofer   Hope   Miranda  
  Description:

Objective Caml, in short OCaml, is an object-orientated, functional language, which additionally supports the imperative programming style.

OCaml has it's origin in Caml. Both are member of the ML (MetaLanguage) family.

Two OCaml programs won the first and second price at the ICFP programming contest (http://www.cs.cornell.edu/icfp/).

OCaml is strict-evaluating, has mutable datastructures, loops, classes, generic classes, modules, lazy streams.

OCaml's Garbage Collector: Generational with two generations (old and new). Stop & Copy on new generation (minor GC), incremental Mark & Sweep on old generation (major GC). Compact memory (complete reordering; generate one large piece of free memeory instead of many small) if no more enough free memory is available.



  Factorial (1)   Michael Neumann
let rec fac n =
  if n > 1 then n * fac (n-1)
  else 1
;;


print_int fac(6);;
Calculates the factorial. Results 720.


  Factorial (2)   Michael Neumann
(* with pattern matching *)

let rec fac n =
  match n with
    0 -> 1
  | n -> n * fac (n-1)
;;


print_int fac(6);;
Calculates the factorial. Results 720.


  gcd   Michael Neumann
let rec ggt p q =
  let r = p mod q in
    if r != 0 then ggt q r
    else q
;;
Greatest common divisor


 Hello World   Michael Neumann
(* Hello World in Objective Caml *)

print_string("Hello World\n");;
Prints "Hello World" onto the screen.


 InsertionSort   Michael Neumann
(* insert e into ordered list lst *)
let rec insert e lst =
  match lst with
    [] -> [e]
  | x :: xs -> if e < x
               then e :: lst
               else x :: (insert e xs) ;;

let insertionSort =
  let insert' a b = insert b a in List.fold_left insert' [] ;;
Sortieren durch Einfuegen


  Length of a list   Michael Neumann
let rec length l =
  match l with
    []           -> 0
  | head :: tail -> 1 + length tail
;;
The length of a list is calculated.


 Squares (functional)   Michael Neumann
List.map(function n -> n * n) [1;2;3;4;5;6;7;8;9;10];;
Outputs the squares from 1 to 10.


 Squares (imperative)   Michael Neumann
for i=1 to 10 do
  print_int (i*i); print_string " ";  
done;;
Outputs the squares from 1 to 10.


 Squares (recursive)   Michael Neumann
let rec iter (a, b) =
   if a <= b then (
      print_int(a*a); 
      print_string(" ");
      iter(a+1, b); )
   else print_newline();;


iter(1,10);;
Outputs the squares from 1 to 10.


 XML-RPC parser   Michael Neumann
(*
 * Copyright (c) 2001 by Michael Neumann
 *
 * this program parses a XML-RPC document
 *
 * $Id: parser.ml,v 1.1 2001/07/26 08:56:40 michael Exp $
 *)


open Pxp_yacc;;
open Pxp_types;;
open Pxp_document;;


(* XML file to load *)
let filename = "methodresponse.xml";;
(*let filename = "methodcall.xml";;*)


type xmlrpc_value =
    X_String  of string
  | X_Integer of int
  | X_Boolean of bool
  | X_Double  of float
  | X_Base64  of string
  | X_Array   of xmlrpc_value list
  | X_Struct  of (string * xmlrpc_value) list
  | X_DateTime_iso8601 of string
;;

type xmlrpc_valtype = XV_Value | XV_Fault ;;
type xmlrpc_type    = XT_Call  | XT_Response | XT_None ;;


exception Wrong_boolean;;
exception Wrong_struct;;



(* returns the #PCDATA string of the child of node `n` *)
let get_sub_data n =
  let children = n # sub_nodes in
    (List.hd children) # data
;;


(* 
 * applies function `fct` on all elements in list `lst`
 * and give the result of that call as parameter of the
 * next call to the next element of the list and so on. 
 *)
let rec apply_children lst fct value =
  match lst with
    hd :: tl -> apply_children tl fct (fct hd value)
  | []       -> value
;;



(* parses the node `node` *)
let rec parse node (typ, valtype, name, params) =

  match node # node_type with

    T_element "methodCall" ->
      let children = node # sub_nodes in
        apply_children children parse (XT_Call, XV_Value, name, params)


  | T_element "methodResponse" ->
      let children = node # sub_nodes in
        apply_children children parse (XT_Response, XV_Value, name, params)


  | T_element "fault" ->
      let children = node # sub_nodes in
        apply_children children parse (typ, XV_Fault, name, params)


  | T_element ("methodName" | "name") ->
      (typ, valtype, get_sub_data node, params)

  | T_element "string" ->
      (typ, valtype, name, params @ [X_String (get_sub_data node)])

  | T_element ("int" | "i4") ->
      (typ, valtype, name, params @ [X_Integer (int_of_string (get_sub_data node))])

  | T_element "boolean" ->
    let boolean = int_of_string (get_sub_data node) in (
      match boolean with
        0 | 1 -> (typ, valtype, name, params @ [X_Boolean (boolean=1)])
      | n     -> raise Wrong_boolean
    )

  | T_element "double" ->
      (typ, valtype, name, params @ [X_Double (float_of_string (get_sub_data node))])

  | T_element "base64" ->
      (typ, valtype, name, params @ [X_Base64 (get_sub_data node)])
      (* TODO: decode *)

   | T_element "dateTime.iso8601" ->
      (typ, valtype, name, params @ [X_DateTime_iso8601 (get_sub_data node)])
      (* TODO: decode *)


  | T_element "array" ->
     let children = node # sub_nodes in
     let (_,_,_,arr)  = apply_children children parse (typ,valtype,"", []) in
       (typ, valtype, name, params @ [X_Array arr])


  | T_element "struct" ->
     let children = node # sub_nodes in
     (* important because element can also be #PCDATA when in non-validating mode! *)
     let mem_children = List.filter (fun e -> match e # node_type with T_element "member" -> true | _ -> false) children in
     let members = List.map (fun ele ->
       let (_,_,name,value) = parse ele (typ,valtype,"",[]) in
         match value with
           value::[] -> (name,value)
         | _         -> raise Wrong_struct
     ) mem_children in
       (typ, valtype, name, params @ [X_Struct members])

  | T_data ->
    let t = (typ, valtype, name, params) in
    (match node # parent # node_type with
      T_element "value" ->
       if List.length (node # parent # sub_nodes) = 1 then
         (typ, valtype, name, params @ [X_String (node # data)])
       else t
    | _ -> t)


  | _ ->
      let children = node # sub_nodes in
        apply_children children parse (typ, valtype, name, params)

;;


(* outputs a value of type `xmlrpc_value` *)
let rec output_argument ele =
  match ele with
    X_String  s  ->  print_endline s
  | X_Integer i  ->  print_int i; print_newline ()
  | X_Boolean b  ->  if b then print_endline "true" else print_endline "false"
  | X_Double  d  ->  print_float d; print_newline ()
  | X_Base64  s  ->  print_endline s
  | X_Array   a  ->  List.iter (fun v -> print_string "  "; output_argument v) a
  | X_Struct  s  ->  List.iter (fun (n,v) -> print_string ("  " ^ n ^ " ==> "); output_argument v) s
  | X_DateTime_iso8601 d -> print_endline d
;;

(*let xmlrpc_parse filename*)

let d = parse_document_entity default_config (from_file filename) default_spec in
let (typ, valtype, name, args) = parse (d # root) (XT_None, XV_Value, "", []) in
  print_endline ("methName: " ^ name);
  List.iter output_argument args
;;
Parses a XML-RPC method call or method response. See http://www.xmlrpc.com for more informations.






 Obliq    up
  similar languages: Modula   Oberon   Leda   Pascal   Phantom   PL/0   PL/0E   YAFL  
 


 Hello World   Michael Neumann
(* Hello World! *)

sys_printText("Hello World\n");
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
for i=1 to 10 do
   sys_printText( text_fromInt(i*i) & " " );
end;
Outputs the squares from 1 to 10.






 Octave    up
 
 


 Hello World   Michael Neumann
# Hello World in Octave

printf("Hello World\n")
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
for i = 1:10
  printf("%d ", i*i);
endfor
Outputs the squares from 1 to 10.






 Ook    up http://www.physics.usyd.edu.au/~mar/esoteric/ook.html
 
 


 Squares   Chad Fowler
Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook.
Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook?
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook. Ook? Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook?
Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook? Ook. Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook? Ook? Ook. Ook! Ook! Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook.
Ook. Ook? Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook!
Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook.
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook?
Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook?
Ook? Ook! Ook? Ook. Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook! Ook. Ook? Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook!
Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook.
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook?
Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook.
Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook?
Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook?
Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook!
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook?
Ook? Ook. Ook! Ook! Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook?
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook? Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook! Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook.
Ook? Ook. Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook?
Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook! Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook? Ook! Ook? Ook.
Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook!
Ook. Ook? Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook!
Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook?
Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook?
Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook!
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook?
Ook? Ook. Ook! Ook! Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook?
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook? Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook! Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook.
Ook? Ook. Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook?
Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook! Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook? Ook! Ook? Ook.
Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook!
Ook. Ook? Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook!
Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook.
Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook?
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook. Ook? Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook?
Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook? Ook. Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook? Ook? Ook. Ook! Ook! Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook.
Ook. Ook? Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook!
Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook.
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook?
Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook?
Ook? Ook! Ook? Ook. Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook! Ook. Ook? Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook!
Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook.
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook?
Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook.
Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook! Ook?
Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook.
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook? Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook! Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook? Ook? Ook.
Ook! Ook! Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook. Ook?
Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook?
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook? Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook.
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook! Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook?
Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook?
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook.
Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook. Ook?
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook.
Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook! Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook? Ook! Ook? Ook. Ook! Ook?
Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook?
Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook. Ook?
Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook?
Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook! Ook? Ook!
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook! Ook? Ook. Ook?
Ook. Ook. Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook? Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook.
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook! Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook?
Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook?
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook. Ook! Ook!
Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook? Ook? Ook. Ook! Ook!
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook?
Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook.
Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook.
Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook! Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook.
Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook.
Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook?
Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook.
Ook? Ook. Ook? Ook. Ook. Ook? Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook? Ook. Ook. Ook. Ook. Ook? Ook? Ook! Ook? Ook. Ook! Ook? Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook. Ook? Ook? Ook.
Ook! Ook. Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook?
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook! Ook?
Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook.
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook? Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook! Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook? Ook? Ook.
Ook! Ook! Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook. Ook?
Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook?
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook? Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook.
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook! Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook?
Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook?
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook.
Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook. Ook?
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook.
Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook! Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook? Ook! Ook? Ook. Ook! Ook?
Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook?
Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook. Ook?
Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook?
Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook! Ook? Ook!
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook.
Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook?
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook. Ook? Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook?
Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook? Ook. Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook? Ook? Ook. Ook! Ook! Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook.
Ook. Ook? Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook!
Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook.
Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook?
Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook?
Ook? Ook! Ook? Ook. Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook! Ook. Ook? Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook!
Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook.
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook?
Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook.
Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook?
Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook?
Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook!
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook?
Ook? Ook. Ook! Ook! Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook?
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook? Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook! Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook.
Ook? Ook. Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook?
Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook! Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook? Ook! Ook? Ook.
Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook!
Ook. Ook? Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook!
Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook!
Ook? Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook?
Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook.
Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook?
Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook?
Ook! Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook!
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook!
Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook?
Ook? Ook. Ook! Ook! Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook?
Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook?
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook? Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook.
Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook! Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook. Ook?
Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook? Ook.
Ook? Ook. Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook?
Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook.
Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook! Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook? Ook! Ook? Ook.
Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook!
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook!
Ook. Ook? Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook. Ook! Ook? Ook! Ook!
Ook? Ook!
Outputs the squares from 1 to 10.






 Oz/Mozart    up http://www.mozart-oz.org
 
 


  Factorial (1)   Michael Neumann
declare
Fact = proc {$ N Z}
          if N > 1 then Z = N * {Fact N-1}
          else Z = 1 end
       end

local Z in
   {Fact 6 Z} {Browse ['Fact(6) = ' Z]}
end
Calculates the factorial. Results 720.


  Factorial (2)   Michael Neumann
declare
proc {Fact N Z}
   if N > 1 then Z = N * {Fact N-1}
   else Z = 1 end
end

local Z in
   {Fact 6 Z} {Browse ['Fact(6) = ' Z]}
end
Calculates the factorial. Results 720.


  Factorial (3)   Michael Neumann
declare
proc {Fact N Z}
   case N
   of 0 then Z = 1
   [] X then Z = X * {Fact X-1}
   end
end

local
   Z
in
   {Fact 6 Z} {Browse ['Fact(6) = ' Z]}
end
Calculates the factorial. Results 720.


  Factorial (4)   Michael Neumann
declare
fun {Fact N}
   case N
   of 0 then 1
   [] X then X * {Fact X-1}
   end
end

{Browse ['Fact(6) = ' {Fact 6}]}
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
% Hello World!!!

{Show 'Hello World'}
Prints "Hello World" onto the screen.


 Hello World (2)   Michael Neumann
% Compile:
%   > ozc -x hw.oz
% Run:
%   > ./hw
functor
import
  Application
  System
define
  {System.printInfo "Hello World\n"}
  {Application.exit 0}
end
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
local ShowIt T in

   proc {ShowIt T}
      {Show T*T}
   end

   {For 1 10 1 ShowIt}
end
Outputs the squares from 1 to 10.


 Squares (2)   Martin Henz
for I in 1..10 do {Show I*I} end
Outputs the squares from 1 to 10.






 Parrot    up http://www.parrotcode.org
 
  Description:

Parrot is register-based virtual machine (JavaVM is stack based). It may be used in forthcoming versions of Perl (Perl6) and Python.

Parrot was initially introduced on April 1st, as an april joke of Larry Wall and G.v.Rossum. They considered to merge their languages Perl and Python into one called Parrot.



 Hello World   Michael Neumann
# Hello World in Parrot

print "Hello World\n"
Prints "Hello World" onto the screen.


 Squares   Chad Fowler
# Squares by Chad Fowler
main:
    set    I0,1
$loop: 
    mul    I1,I0,I0
    print  I1 
    print  "\n"
    inc    I0,1 
    eq     I0,11,$done
    branch $loop
$done:   
    end  
Outputs the squares from 1 to 10.






 Pascal    up
  similar languages: Modula   Oberon   Obliq   Leda   Phantom   PL/0   PL/0E   YAFL  
 


 Hello World   Michael Neumann
PROGRAM HelloWorld;

BEGIN
   WRITELN('Hello World');
END.
Prints "Hello World" onto the screen.


 Hello World   ISO-7185   Andreas K. Foerster
PROGRAM HelloWorld (OUTPUT);

BEGIN
   WRITELN('Hello World');
END.
Prints "Hello World" onto the screen.






 Perl    up http://www.perl.com
 
 


  Factorial (1)   Michael Neumann
sub fac {
  my ($n) = @_;

  if ($n < 2) {
    return $n;
  }
  else {
    return $n * fac($n-1);
  }
}

print fac(6), "\n";
Calculates the factorial. Results 720.


  Factorial (2)   Arnaud ASSAD
#!/usr/bin/perl

sub fac {
  $_[0]>1?$_[0]*fac($_[0]-1):1;
}

print fac(6);
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
# Hello World in Perl

print "Hello World\n";
Prints "Hello World" onto the screen.


 References   Michael Neumann
# array -> reference
@arr      = (1, 2, 3);
$arr_ref  = \@arr;

# reference -> array
$arr_ref2 = [1, 2, 3];
@arr2     = @$arr_ref2;

# array access
$item     = $arr[0];
$item     = $arr_ref->[0];
References and Arrays; Array access


 Squares (1)   Michael Neumann
for($i = 1; $i <= 10; ++$i) {
   print $i*$i, ' ';
}
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
@squares = ();

foreach my $i (1..10) {
  push(@squares, $i * $i);
}

print join(" ", @squares), "\n";
Outputs the squares from 1 to 10.


 Squares (3)   Pixel
print join(" ", map { $_ ** 2 } 1..10), "\n";
Outputs the squares from 1 to 10.


 Squares (4)   Arnaud ASSAD
for (1..10) { print $_**2," "};print$/;
Outputs the squares from 1 to 10.


 Substitution   Michael Neumann
$a = 3;
$b = 5;
$c = $a + $b;

print "$a + $b = $c";
Prints 3 + 5 = 8 onto the screen.






 Phantom    up
  similar languages: Modula   Oberon   Obliq   Leda   Pascal   PL/0   PL/0E   YAFL  
 


 Hello World   Michael Neumann
(* Hello World! *)

module helloworld;

import stdio;

begin
   stdio.puts("Hello World\n");
end helloworld.
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
module Squares;

import stdio, fmt;

begin
   for i:=1 to 10 do
      stdio.puts(fmt.fint(i*i) @ " ");
   end;
end Squares.
Outputs the squares from 1 to 10.






 PHP    up http://www.php.net
 
 


 Hello World   PHP3   Michael Neumann
<?php
   echo "Hello World\n";
?>
Prints "Hello World" onto the screen.


 Squares   PHP3   Michael Neumann
<?php
// gibt die Quadrate von 1-10 aus

for($i = 1; $i <= 10; ++$i)
{
   echo $i*$i;
   echo " ";
}
?>
Outputs the squares from 1 to 10.






 Pico    up http://pico.vub.ac.be/
 
 


 Eulersche Number   Michael Neumann
{      
   "Fakultät";
   !n: if(n>1, n * !(n-1), 1);
   
   "Reziprok";
   %n: 1 / n;
   
   e: 0;
   n: -1;
   lp[10]: {
      n := n+1;
      e := e + %(!n)
   };
   
   "e ausgeben";
   display(e)
}
Calculates the eulersche-number (e=2.71828).


  Factorial   Michael Neumann
{
   fac(n): if(n>1, n*fac(n-1), 1);
   
   display( fac(6) )
}
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
{
   "da es in Pico keine Kommentare gibt,";
   "verwende ich einfach Strings.";
   
   display('Hello World', eoln)
}
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
for (i:1, i:=i+1, i<11, display(i^2, " "))
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
{
   n: 0;
   t[10]: {n: n+1; n*n};
   display(t)
}
Outputs the squares from 1 to 10.






 Pike    up http://pike.ida.liu.se/
  similar languages: C   C#   C++   C-Talk   D   Cilk   Java   Objective-C   TOM  
 


  Factorial   Michael Neumann
/* 
 * Berechnen der Fakultät
 */


// Fakultät-Funktion
int fac(int n)
{
   if(n > 1) return n * fac(n-1);
   else return 1;
} 

// Hauptprogramm
void main() 
{
   write("" + fac(6));
}
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
// Hello World in Pike

void main()
{
   write("Hello World\n");
}
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
void main() 
{
   string str = "";
   
   for(int i=1; i<=10; i++)
   {
      str += i*i + " ";
   }
   
   write(str);
}
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
void main() 
{
   array arr = ({ 1,2,3,4,5,6,7,8,9,10 });
     
   foreach(arr, int i)
   {
      write(i*i + " ");
   }
}
Outputs the squares from 1 to 10.






 PL/0    up
  similar languages: Modula   Oberon   Obliq   Leda   Pascal   Phantom   PL/0E   YAFL  
 


 Hello World   Michael Neumann
"Hello World" is in PL/0 not possible, because there are no strings only integer.


 Squares   Michael Neumann
VAR x, squ;

PROCEDURE square;
BEGIN
   squ := x * x
END;

BEGIN
   x := 1;
   WHILE x <= 10 DO
   BEGIN
      CALL square;
      !squ
   END
END.
Outputs the squares from 1 to 10.






 PL/0E    up
  similar languages: Modula   Oberon   Obliq   Leda   Pascal   Phantom   PL/0   YAFL  
 


 Hello World   Michael Neumann
PROGRAM HelloWorld;

BEGIN
   WRITELN('Hello World');
END.
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
PROGRAM HelloWorld;

VAR i : LONGINT;

BEGIN
   i = 1;
   
   REPEAT
      WRITE(i*i,' ');
      inc(i);
   UNTIL i>10;
END.
Outputs the squares from 1 to 10.






 PL/1    up
 
 


 Hello World   B. Bora Bali
HELLO: PROCEDURE OPTIONS (MAIN);

  PUT SKIP LIST('HELLO WORLD!');

END HELLO;
Prints "Hello World" onto the screen.


 Squares   B. Bora Bali
SQUARE: PROCEDURE OPTIONS (MAIN);

   DECLARE I FIXED DECIMAL(5) INIT(1);  

   DO WHILE (I <= 10);
      PUT SKIP LIST(I**2);
      I = I + 1; 
   END;

END SQUARE;
Outputs the squares from 1 to 10.






 PL/SQL    up
 
 


 Hello World   Michael Neumann
BEGIN
  DBMS_OUTPUT.put_line('Hello World');
END;
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
DECLARE
  square INT;
BEGIN
  FOR i IN 1..10 LOOP
    square := i * i;
    DBMS_OUTPUT.put_line( to_char(square) || ' ' );
  END LOOP;
END;
Outputs the squares from 1 to 10.






 Pliant    up http://fullpliant.org
 
  Description: Pliant's special feature is its dynamic compiler. Small programs can be immediately started like in an interpreter, large programs can be precompiled to reduce the time until the program is ready to run. Pliant is an open language, i.e. you can extend the parser and compiler (of course in Pliant).


  Factorial   Michael Neumann
# shunt ist C's ?: Operator

function fac x -> f
   arg Int x f
   f := shunt x>1 x*(fac x-1) 1


console fac:6
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
# Hello World in Pliant

console "Hello World" eol
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
function Squares
   var Int i
   for i 1 10
      console i * i " "


# Funktion aufrufen
Squares
Outputs the squares from 1 to 10.






 Postscript    up
  similar languages: Forth  
 


 Hello World   Michael Neumann
% Hello World

/Courier findfont 
28 scalefont
setfont
0 0 moveto
(Hello World) show     % Text links unten ausgeben
showpage
Prints "Hello World" onto the screen.






 Profan    up http://www.profan.de
  similar languages: ABC   Amos   BASIC   Euphoria   REXX  
 


 Hello World   Michael Neumann
PRINT "Hello World"
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
' gibt die Quadrate von 1-10 aus

DECLARE I%
LET I% = 0

WHILENOT @Equ(I%, 10)
   INC I%
   PRINT @Sqr(I%); " ";
WEND
Outputs the squares from 1 to 10.






 Prolog    up
 
 


  Factorial   Michael Neumann
Calculate the factorial

fak(0,1).
fak(N,R) :-  N > 0,  M is N - 1,  fak(M,R1),  R is N * R1.

?- fak(6,N).
Calculates the factorial. Results N = 720


 Finite Domain Constraint Programming   Michael Neumann
solve(A, B, C, D, E, F, G, H, I) :-
  (
    between(1,9,A),
    between(1,9,B), B =\= A,
    between(1,9,C), C =\= B, C =\= A,
    between(1,9,D), D =\= C, D =\= B, D =\= A,
    between(1,9,E), E =\= D, E =\= C, E =\= B, E =\= A,
    between(1,9,F), F =\= E, F =\= D, F =\= C, F =\= B, F =\= A,
    between(1,9,G), G =\= F, G =\= E, G =\= D, G =\= C, G =\= B, G =\= A,
    between(1,9,H), H =\= G, H =\= F, H =\= E, H =\= D, H =\= C, H =\= B, H =\= A,
    between(1,9,I), I =\= H, I =\= G, I =\= F, I =\= E, I =\= D, I =\= C, I =\= B, I =\= A,
    A + B + G =:= 15,
    C + D + H =:= 15,
    E + F + I =:= 15,
    G + H + I =:= 15,

    A + B + C + D + E + F =:= 30
  ).


/* 
  Call it from the Prolog command prompt as follows:

   ?- solve(A, B, C, D, E, F, G, H, I).
*/
The problem: Each questionmark represents a number from 1 to 9 (no two questionmarks may have the same number). Choose the numbers so that the sum of each triangle in the picture below is 15 and the sum of all numbers on the circle is 30.



 Hello World   Michael Neumann
?- write('Hello World'), nl.
Prints "Hello World" onto the screen.






 Python    up http://www.python.org
 
 


 gcd   Michael Neumann
#
# Größter Gemeinsamer Teiler
# 

def ggt(a, b):
   if a < b: a,b = b,a
   while a%b != 0:
      a,b = b,a%b
   return b
Greatest common divisor


 Hello World   Michael Neumann
# Hello World in Python

print "Hello World"
Prints "Hello World" onto the screen.


 OO - Shape, Circle, Rectangle   Michael Neumann
from math import pi

class Color:
  def __init__(self, red=0, green=0, blue=0):
    self.red   = red
    self.green = green
    self.blue  = blue

# no abstract classes in Python!
class Shape:
  def __init__(self, x, y, color):
    self.x     = x
    self.y     = y
    self.color = color

  def draw(self):
    raise "abstract method"

  def getArea(self):
    raise "abstract method"

  def move(self, x, y):
    self.x += x
    self.y += y

class Circle(Shape):
  def __init__(self, x, y, radius, color):
    Shape.__init__(self, x, y, color)
    self.radius = radius

  def draw(self):
    pass # do something here

  def getArea(self):
    return int(pi * self.radius)

class Rectangle(Shape):
  def __init__(self, x, y, width, height, color):
    Shape.__init__(self, x, y, color)
    self.width  = width
    self.height = height

  def draw(self):
    pass # do something here

  def getArea(self):
    return self.width * self.height


## Test the Classes ##

BLACK  = Color()
WHITE  = Color(255, 255, 255)

circle = Circle(100, 100, 50, BLACK)
rect   = Rectangle(20, 20, 5, 5, WHITE)

circle.move(10, 10)

circle.x = 50
circle.radius = 5

print circle.getArea()     # => 15
print rect.getArea()       # => 25

print rect.width           # => 5
rect.width = 10
print rect.width           # => 10 

circle.draw()
rect.draw()



 QuickSort   Michael Neumann
#
# QuickSort in Python
# von Michael Neumann
# 

def quicksort(arr):
   if len(arr) <= 1: return arr
   m = arr[0]
   return quicksort(filter(lambda i,j=m: i<j, arr)) + \
          filter(lambda i,j=m: i==j, arr) + \
          quicksort(filter(lambda i,j=m: i>j, arr))



# Aufruf
print quicksort([5,99,2,45,12,234,29,0])
QuickSort


 Squares (1)   Michael Neumann
arr = range(1,11)

for i in arr: print i*i,
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
for i in map(lambda a: a*a,range(1,11)): print i,
Outputs the squares from 1 to 10.






 R    up http://www.r-project.org
 
  Description: R is GNU's implementation of the programming-language S. It is used mainly for statistical purposes.


 Hello World   Michael Neumann
# Hello World in R

print("Hello World")
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
for (i in 1:10) print(i*i)
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
r <- 1:10       # assignment
print(r*r)
Outputs the squares from 1 to 10.






 Ratfor    up http://sepwww.stanford.edu/software/ratfor.html
 
  Description: NetBSD's devel/ratfor package description says: Ratfor is a preprocessor for Fortran code that allows the use C-like flow expressions. Ratfor was invented by Brian Kernigham. Statements on a line may be separated by a ";". Statements may be grouped together with braces }. Do loops do not require statement numbers because {} defines the range, etc. The Fortran relational operators .gt.,.ge,.ne., etc. may be written >,<=,!=,etc. All of these are translated into Fortran 77 by Ratfor. Ratfor also frees you from Fortran's strict indentation rules. Anything from a # to the end of the line is a comment.


 Hello World   Daniel Lundin
# hello.ratfor
print *, 'Hello, world'
end
Prints "Hello World" onto the screen.






 Rebol    up http://www.rebol.com
 
 


  Factorial (1)   chaz
fact: func [nummer] 
    [either equal? nummer 1 
        [1] 
        [multiply nummer fact subtract nummer 1]
    ]



fact 6
Calculates the factorial. Results 720.


  Factorial (2)   chaz
factorial: func [num][
    fact: func [n a] [
        any [
            if lesser? n 0 [0]              
            switch n [0 1 a]                
            fact subtract n 1 multiply n a  
        ]
    ] 
    fact num 1
]


factorial 6
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
print "Hello World"
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
repeat i 10 [prin i * i prin " "]
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
for i 1 10 1 [prin i * i prin " "]
Outputs the squares from 1 to 10.


 Squares (3)   chaz
print repeat i 10 [append [] multiply i i]
Outputs the squares from 1 to 10.






 REXX    up
  similar languages: ABC   Amos   BASIC   Euphoria   Profan  
 


 Hello World   Michael Neumann
/* Hello World (Kommentar ist notwendig!!!) */

SAY "Hello World"
Prints "Hello World" onto the screen.


 Quicksort   H. Wonner
Quicksort: PROCEDURE expose A.
PARSE ARG lo, hi
/* lo ist der unterste Index, hi ist der oberste Index 
   des zu sortierenden (Teil-)Feldes A. */

/* Aufteilung */

i = lo
j = hi
Pivot = (lo + hi) % 2
x = a.Pivot
Do Until i > j
  Do While a.i < x
    i = i + 1
  end
  Do While a.j > x
    j = j - 1
  end
  if i <= j then do
    h   = a.i
    a.i = a.j
    a.j = h
    i   = i + 1
    j   = j - 1
  end
end

/* Rekursion */

if lo < j then call quicksort lo, j
if i < hi then call quicksort i, hi

Return 0
^Z

Quicksort sorting algorithm


 Squares (1)   Michael Neumann
/* */

DO I=1 TO 10
   SAY I*I
END
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
/* */

I=1

DO 10
   SAY I*I
   I = I + 1
END
Outputs the squares from 1 to 10.






 Ruby    up http://www.ruby-lang.org
 
  Description: Ruby is the interpreted programming language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, and extensible.


 Binary Search Tree   Michael Neumann
#
# $Id: binary_tree.rb,v 1.1 2001/10/07 11:58:07 michael Exp $
#
# BinaryTree by Michael Neumann 
#

class BinaryTree
  class Node
    attr_reader :value, :left, :right

    def initialize( value, left=nil, right=nil)
      @value = value
      @left, @right = left, right
    end

    def insert( value )
      if value >= @value then
        # insert right
        if @right.nil?
          @right = Node.new( value )
        else
          @right.insert( value )
        end
      else
        # insert left
        if @left.nil?
          @left = Node.new( value )
        else
          @left.insert( value )
        end
      end
    end

    # depth first (from left to right)
    def traverse(&b)
      @left.traverse(&b) if @left
      b.call(self)
      @right.traverse(&b) if @right
    end
  end

  attr_reader :root

  def initialize
    @root = nil
  end

  def insert( value )
    if @root.nil?
      @root = Node.new( value )
    else
      @root.insert( value )
    end
  end

  def traverse(&b)
    return if @root.nil?
    @root.traverse(&b)
  end
end

def binary_sort( array )
  tree = BinaryTree.new

  # fill tree with array elements
  array.each do |e|
    tree.insert( e )
  end

  sorted_array = []
  tree.traverse do |node|
    sorted_array << node.value
  end

  return sorted_array
end

if __FILE__ == $0
  p binary_sort( [0,6,4,3,5,8,4,6] ) # => [0, 3, 4, 4, 5, 6, 6, 8]
end
Binary Search Tree used to sort an array by traversing it with DFS (depth-first-search).


 Calculate PI   Yukihiro Matsumoto?
k, a, b, a1, b1 = 2, 4, 1, 12, 4

while TRUE
  # Next approximation
  p, q, k = k*k, 2*k+1, k+1
  a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1
  # Print common digits
  d = a / b
  d1 = a1 / b1
  while d == d1
    print d
    $stdout.flush
    a, a1 = 10*(a%b), 10*(a1%b1)
    d, d1 = a/b, a1/b1
  end
end
Calculating PI


 Calculate PI   Michael Neumann
#
# From the paper "Un Unbounded Spigot Algorithm for the Digits of Pi"
# http://web.comlab.ox.ac.uk/oucl/work/jeremy.gibbons/publications/spigot.pdf
#

def pi
  q, r, t, k = 1, 0, 1, 1
  loop do
    n = (3*q+r) / t
    if (4*q+r) / t == n then
      yield n
      q, r, t, k = 10*q, 10*(r-n*t), t, k
    else
      q, r, t, k = q*k, q*(4*k+2)+r*(2*k+1), t*(2*k+1), k+1
    end
  end
end

pi {|n| print n; $stdout.flush }
Calculating PI


  Factorial   Michael Neumann
def fac(n)
  if n < 2 then
    n
  else 
    n * fac(n-1)
  end
end


# call it
print fac(6)
Calculates the factorial. Results 720.


  Factorial (2)   Michael Neumann
def fac(n)n>1?n*fac(n-1):1 end

puts fac(6)
Calculates the factorial. Results 720.


  Factorial (tail-recursive)   Michael Neumann
def fac(n, res=1)
  if n < 2 then
    res 
  else 
    fac(n-1, n*res)
  end
end


# call it
print fac(6)
Calculates the factorial. Results 720.


 gcd   Michael Neumann
#
# Größter Gemeinsamer Teiler
# 

def ggt(a, b)
   a,b = b,a if a < b
   a,b = b,a%b while a%b != 0
   return b
end
Greatest common divisor


 Hash1 - Standard hash-function   Michael Neumann
def hash1( txt, m = 101 )
   h = 0
   txt.each_byte { |i| h = ((h<<8) + i) % m}
   return h
end
Simple hash-algorithm


 hashpjw   Michael Neumann
#
# hashpjw, algorithm by P.J.Weinberg
#
# implemented by Michael Neumann
#

def hashpjw(txt, m=101)
   h = 0
   txt.each_byte {|i|
      h = (h << 4) + i
      g = h & 0xf0000000
      h ^= (g >> 24) ^ g if g
   }
   return h%m
end
Hashfunction of P.J. Weinberg


 Heapsort   Michael Neumann
#
# $Id: heapsort.rb,v 1.1 2001/10/06 18:48:30 michael Exp $
#
# in-place Heapsort by Michael Neumann 
#

class Array
  def heapsort!
    a = self
    n = a.size
    a.unshift nil    # add 0'th element  

    ##
    # (1) construct heap
    #
    2.upto(n) do | i |
      # insert element a[i] into heap a[1..i-1]
      cnode = i
      while cnode != 1 and a[cnode] > a[cnode/2] do
        a[cnode], a[cnode/2] = a[cnode/2], a[cnode]
        cnode /= 2
      end
    end

    ##
    # (2) remove elements from heap 
    #
    n.downto(2) do | i |
      a[1], a[i] = a[i], a[1]
      cnode = 1
      while cnode*2 < i do
        if cnode*2+1 >= i or a[cnode*2] > a[cnode*2+1]
          # no right node exist or left > right
          if a[cnode] < a[cnode*2]   # cnode < left
            a[cnode], a[cnode*2] = a[cnode*2], a[cnode]
            cnode *= 2
          else
            break
          end
        else
          # right > left
          if a[cnode] < a[cnode*2+1]   # cnode < right
            a[cnode], a[cnode*2+1] = a[cnode*2+1], a[cnode]
            cnode = cnode*2+1
          else
            break
          end
        end
      end # do
    end

    a.shift     # remove 0'th element
    return a
  end

  def heapsort
    self.dup.heapsort!
  end
end

if __FILE__ == $0
  a = [6, 3, 5, 3 ,8, 5, 3, 7, 4, 2, 3]
  p a.heapsort
end
Heapsort (in-place), runtime is in O(n * log(n))


 Hello World (1)   Michael Neumann
# Hello World in Ruby

print "Hello World\n"
Prints "Hello World" onto the screen.


 Hello World (2)   Michael Neumann
"Hello World\n".display
Prints "Hello World" onto the screen.


 OO - Shape, Circle, Rectangle   Michael Neumann
class Color
  attr_accessor :red, :green, :blue

  def initialize(red=0, green=0, blue=0)
    @red, @green, @blue = red, green, blue
  end
end

# no abstract classes in Ruby!
class Shape
  attr_accessor :x, :y, :color

  def initialize(x, y, color)
    @x, @y, @color = x, y, color
  end

  def draw
    raise "abstract method"
  end

  def getArea
    raise "abstract method"
  end

  def move(x, y)
    @x += x
    @y += y
  end
end

class Circle < Shape
  attr_accessor :radius

  def initialize(x, y, radius, color)
    super(x, y, color)
    @radius = radius
  end

  def draw
    # do something here
  end

  def getArea
    Integer(Math::PI * radius)
  end
end

class Rectangle < Shape
  attr_accessor :width, :height

  def initialize(x, y, width, height, color)
    super(x, y, color)
    @width, @height = width, height
  end

  def draw
    # do something here
  end

  def getArea
    @width * @height
  end
end

## Test the Classes ##

BLACK  = Color.new
WHITE  = Color.new(255, 255, 255)

circle = Circle.new(100, 100, 50, BLACK)
rect   = Rectangle.new(20, 20, 5, 5, WHITE)

circle.move(10, 10)

circle.x = 50
circle.radius = 5

p circle.getArea     # => 15
p rect.getArea       # => 25

p rect.width         # => 5
rect.width = 10
p rect.width         # => 10 

circle.draw
rect.draw



 Quicksort   Michael Neumann
def quicksort( arr )
   return arr if arr.size <= 1
   m = arr[0]
   return quicksort( arr.select { |i| i < m } ) + 
          arr.select { |i| i == m } + 
          quicksort( arr.select { |i| i > m } )
end


# Aufruf
print quicksort( [5, 99, 2, 45, 12, 234, 29, 0] ).join( " " )
Quicksort sorting algorithm


 RC4   Michael Neumann
s, j, k = (0..255).to_a, 0, (ARGV[0]*256)[0,256].unpack('C*')
(0..255).each{|x| j = (j + s[x] + k[x]) % 256; s[x], s[j] = s[j], s[x] }
i = j = 0; $stdin.each_byte{|b| i = (i + 1) % 256; j = (j + s[i]) % 256
s[i], s[j] = s[j], s[i]; $stdout<<(b ^ s[(s[i] + s[j])%256]).chr }
RC4 stream chiper (algorithm by Ron Rivest, RSA)


  Sieve of Eratosthenes   Michael Neumann
# $Id: prime.rb,v 1.2 2001/10/16 11:00:12 michael Exp $

class Primes
  def initialize(n = 10_000)
    @n = n
    @primes = 0

    # Sieve of Eratosthenes
    k = 2
    while k < Math.sqrt(@n)
      if @primes[k] == 0
        j = 2*k
        while j <= @n
          @primes |= (1 << j)
          j += k
        end
      end
      k += 1
    end
  end

  def is_prime?( number )
    if number > @n
      raise "number to big"
    else
      @primes[number] == 0
    end
  end

  alias prime? is_prime?
end

if __FILE__ == $0
  x = Primes.new(10_000)
  p x.prime?(77)   # => false
  p x.prime?(13)   # => true
  p x.prime?(100)  # => false
end
Calculates all primes upto a given number.


 Squares (1)   Michael Neumann
for i in 1..10 do
   print i*i, " "
end
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
(1..10).each { |i| print i*i, " " }
Outputs the squares from 1 to 10.


 Squares (3)   Michael Neumann
1.upto(10) do |i| puts i**2 end
Outputs the squares from 1 to 10.


 Squares (4)   Michael Neumann
i = 1
until i > 10 do
  puts i**2
  i += 1
end
Outputs the squares from 1 to 10.






 Sather    up http://www.gnu.org/software/sather
  similar languages: Blue   Eiffel  
  Description: Sather is an Eiffel-like language. It features:
  • Pre/Post Conditions, Invariants
  • Closures
  • Iterators
  • Multiple Inheritance through mixins
  • Parameterized Classes
  • Abstact datatypes (similar to Java's interfaces), classes, partial classes, code sharing by "including", immutable classes
  • Supertypes (inserting classes not below, but above an existing class)
  • Contravariance conformance - unlike Eiffel's unsafe covariance.
  • Short cuts for attributes, constants etc, or variable declaration without specifying explicitly the type.
  • Garbage Collector
  • Very fast


  Factorial   Michael Neumann
class MAIN is

  fac(n : INT) : INT is
    if n <= 1 then
      return 1;
    else
      return n * fac(n-1);
    end
  end;

  main is
    #OUT + fac(6) + "\n";
  end;

end;
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
class MAIN is

   main is
      #OUT + "Hello World\n";
   end; -- main
   
end; -- class MAIN
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
class MAIN is

  squares : STR is
    r ::= "";          -- implicit type
    loop r := r + (1.upto!(10) ^ 2) + " " end;
    return r;
  end;

  main is
    #OUT + squares + "\n";
  end;

end;
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
class MAIN is

  -- squares! is an iterator yielding the squares of the 
  -- numbers from "from" to "to".
  squares!(once from : INT, once to : INT) : INT is
    loop
      i ::= from.upto!(to);
      yield i * i
    end
  end;

  main is
    loop #OUT + squares!(1, 10) + " " end;
    #OUT + "\n";
  end;

end;
Outputs the squares from 1 to 10.


 Squares (3)   Michael Neumann
class MAIN is

  squares is
    a : ARRAY{INT}    := |1,2,3,4,5,6,7,8,9,10| ;
    b : ROUT{INT}:INT := bind(_.pow(2));  -- a closure 

    a.map(b);

    loop #OUT + a.elt! + " " end;
  end;

  main is
    squares;
    #OUT + "\n";
  end;

end;
Outputs the squares from 1 to 10.






 Scheme    up
  similar languages: Lisp  
  Description: A Lisp-like language.


  Factorial   Michael Neumann
; define function
(define fak 
    (lambda (n) 
      (if (< n 2)
          1
          (* n (fak (- n 1)))
          )
      )
    )

; call function
(fak 6)
Calculates the factorial. Results 720.


 Hello World (1)   Michael Neumann
; Hello World in Scheme

(display "Hello World")
Prints "Hello World" onto the screen.


 Hello World (2)   J. A. Durieux
; Hello World
"Hello, world!"
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
(do 
    ; Initialize variables
    ( 
     (i 1 (+ i 1))
    )
    
    ; while condition
    (
     (> i 10)
    )
    
    ; loop body
    (display (* i i))
    (display " ")    
)
Outputs the squares from 1 to 10.


 Squares (2)   J. A. Durieux
; Squares
(define (squares from to)
  (if (> from to) '()
      (cons (* from from)
            (squares (+ from 1) to) ) ) )

(squares 0 10)
Outputs the squares from 1 to 10.






 Shell-Sprachen    up
  similar languages: DOS Batch  
 


 Squares   csh   Michael Neumann
# Comment in csh (not at the command-line!)
set i=1
while ($i <= 10)
  @ square=$i * $i
  echo -n $square ""
  @ i++
end
Outputs the squares from 1 to 10.


 Squares   es (Extensible Shell)   Michael Neumann
for (i=1 2 3 4 5 6 7 8 9 10) {
   echo -n `{ expr $i \* $i }' '
}
Outputs the squares from 1 to 10.


 Factorial   sh,ksh,zsh,bash   Michael Neumann
#! /bin/sh

#
# Calculates the factorial
#

if [ $# != 1 ]
then
   echo "FEHLER: Aufruf $0 Wert" >&2
   exit 1
fi
 
case $1 in
[01]) echo $1 ;;
*)    n=`expr $1 - 1`
      m=`$0 $n`        # $0 ist der Programm-Name
      echo `expr $1 \* $m`  
      ;;
esac
Calculates the factorial. The call fac 6 results 720


 Squares   sh,ksh,zsh,bash   Michael Neumann
squares=

for i in 1 2 3 4 5 6 7 8 9 10
do
   squares=$squares`expr $i \* $i`" "
done

echo $squares
Outputs the squares from 1 to 10.


 Hello World   sh,ksh,zsh,bash,csh,es   Michael Neumann
# Hello World!

echo Hello World
Prints "Hello World" onto the screen.


 Hello World   WSH (Windows Scripting Host)   Eric Vitiello
WScript.Echo "Hello World"
Prints "Hello World" onto the screen.


 Bookmark Script   zsh   Michael Neumann
#!/usr/bin/env zsh
#
# $Id: c,v 1.1 2001/07/20 18:18:10 michael Exp $
#
# Bookmark script for zsh
# by Michael Neumann (mneumann@ntecs.de)
#
# You have to type:
#
#   fpath=(.)     # or directory in which "c" lies
#   autoload c
#
# to make sure, that the function c is
# invoked by zsh when you type "c".
#


dirs=(
  /usr/pkgsrc
)

if [[ $# == 0 ]] ; then
  cnt=1
  for i in $dirs ; do
    echo "[$cnt]\t$i"
    cnt=`expr $cnt + 1`
  done
else
  # reload array dirs
  if [[ $1 == -r ]] ; then
    unfunction $0
    autoload $0
  else
    nr=`expr $1 : '\([0-9]*\)$'`

    if [[ $nr != '' ]] ; then          # it's a number
      if [[ $nr -le $#dirs && $nr -gt 0 ]] ; then
        cd $dirs[$nr]
      else
        echo "False bookmark number"
      fi
    else
      cnt=1
      match_dirs=()
      for i in $dirs ; do
        if [[ `expr $i : '.*'$1` -gt 0 ]] ; then  # matches entry
          match_dirs[$cnt]=$i
          cnt=`expr $cnt + 1`
        fi
      done

      if [[ $#match_dirs == 0 ]] ; then
        echo "Nothing found"
      elif [[ $#match_dirs == 1 ]] ; then
        cd $match_dirs[1]
        pwd
      else
        cnt=1
        for i in $match_dirs ; do
          echo "[$cnt]\t$i"
          cnt=`expr $cnt + 1`
        done
        echo -n "? "; read i
        cd $match_dirs[$i]
      fi
    fi
  fi
fi
Bookmark Script






 Simula    up
  similar languages: Ada   ALGOL  
 


 Hello World   Simula 67   Michael Neumann
begin
   OutText("Hello World");
   OutImage
end
Prints "Hello World" onto the screen.


 Squares   Simula 67   Michael Neumann
comment
   gibt die Quadrate von 1 bis 10 aus;
   
begin
   integer i;     ! ein Integer;

   for i := 1 step 1 until 10 do
   begin
      OutInt(i*i,4);
   end--for-----diese Schleife gibt die Quadrate aus;

   OutImage
end--Ende des Programmes
Outputs the squares from 1 to 10.






 Sina    up
 
 


 Hello World   Michael Neumann
class HelloWorld interface
   methods
      show returns nil;      
   inputfilters
      disp: Dispatch = {inner.*};    
end;

class HelloWorld implementation
   methods      
      show
      begin
         self.printLine('Hello World');
      end;      
end;


main
   temps
      hello: HelloWorld;   
   begin
      hello.show
   end

Prints "Hello World" onto the screen.






 Sirius    up
 
 


 Hello World   Michael Neumann
@ Hello World in Sirius @

PROGRAM Hello_World
   OUTPUT ('Hello World')
END
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
PROGRAM Squares

PROCEDURE iterate (INTEGER start, ende)
   DECLARE i AS INTEGER

   WHILE (start <= ende)
      i := start * start
      OUTPUT (i)
      start := start + 1
   NEXT
END

iterate (1, 10)

END
Outputs the squares from 1 to 10.






 Sisal    up
 
 


 Hello World   Michael Neumann
%
% Hello World!!!
%

define main

function main(returns array [Character])
   "Hello World"
end function
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
define main

function main(returns array [Integer])

   for i in 1, 10
      x := i * i      
      returns array of x
   end for
   
end function
Outputs the squares from 1 to 10.






 Smalltalk    up
 
 


 Hello World   Michael Neumann
"Hello World in Smalltalk"

'Hello World' out.
Prints "Hello World" onto the screen.


 Quicksort   Michael Neumann
" This must be inserted into the class Array as an instance method "


quicksort: l to: r
" sorts the array between l and r after the quicksort method 
  by Michael Neumann 1998
"
| m il ir temp |
   (r > l) ifTrue: [
      m := self at: ((l + r) // 2).
      il := l.
      ir := r.
      [
         [(self at: il) < m] whileTrue: [il := il + 1.].
         [(self at: ir) > m] whileTrue: [ir := ir - 1.].
         (il < ir) ifTrue: [
            " swap "
            temp := self at: il.
            self at: il put: (self at: ir).
            self at: ir put: temp.
         ].
      ] doUntil: [il >= ir.].
      self quicksort: l to: (il - 1).
      self quicksort: (il + 1) to: r.
   ].
^self.
Quicksort sorting algorithm


 Squares (1)   Michael Neumann
| someNumbers |
someNumbers := {1 2 3 4 5 6 7 8 9 10}
(someNumbers collect: [:i| i squared.]) out.
Outputs the squares from 1 to 10.


 Squares (2)   Aaron Jon Reichow
1 to: 10 do: [ :i | Transcript show: (i squared)]
Outputs the squares from 1 to 10.






 SML    up http://www.standardml.org/
 
 


 Hello World   Michael Neumann
print "Hello World\n";
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
fun iter (a,b) =
   if a <= b then (print(Int.toString(a*a) ^ " "); iter(a+1,b) )
   else print "\n";

iter(1,10);
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
fun iter 0 = ""
|   iter n = (iter(n-1); print(Int.toString(n*n) ^ " "); "\n");

print(iter 10);
Outputs the squares from 1 to 10.


 Word Tokenizer   Michael Neumann
fun wordTokenizer (reader : (char, TextIO.StreamIO.instream) StringCvt.reader)
                  (strm : TextIO.StreamIO.instream) = let

  fun scan s (l: char list) (charState: bool) =
    case (reader s)
      of NONE => (l, s)
       | SOME (c, s) =>
         if Char.isAlpha c then scan s (l @ [c]) true
         else if charState then (l, s)
         else scan s l charState

  val (res, s) = scan strm [] false

in
  if res = [] then NONE
  else SOME (implode res, s)
end


fun lowerCaseFilter s =
  case s
    of NONE => NONE
     | SOME w => SOME (String.map Char.toLower w)


fun main (cmd:string, args:string list):OS.Process.status = let
  val (fileName::_) = args
  val ins = TextIO.openIn fileName

  val ws = lowerCaseFilter o TextIO.scanStream wordTokenizer

  fun loop () = case ws ins
                  of NONE => ()
                   | SOME word => (print word; print "\n"; loop ())
in
  loop ();
  0
end

fun test () =
  main ("tokenizer", ["tokenizer.sml"])
Splits a given file into words and outputs them. Makes use of SML streams.


 Hello World   SML/NJ   Michael Neumann
(*
  To make a heap image of this file, load it into the 
  interactive compiler (you do this by starting "sml" at 
  the command line; then issue a 'use "thisfile.sml"'). 
  Type then:

    SMLofNJ.exportFn ("heapimage", main);

  Exit now the interactive compiler. To load the heap image,
  type (at the command line):

    sml @SMLload=/path/to/heapimage.ext

  (where ext is a platform dependend suffix, e.g. "x86-bsd", to
   distinguish heap images of different OSes and platforms)
*)

fun main (cmd:string, args:string list):OS.Process.status =
(
  print "Hello world\n";
  0
);
Prints "Hello World" onto the screen.






 SNOBOL    up
 
  Description: SNOBOL is dynamic typed, garbage-collected and has build-in pattern-matching. Because of the build-in pattern-matching, SNOBOL is suitable for text-manipulation and processing.


  Factorial   SNOBOL4   Michael Neumann
*
* Berechnen der Fakultät
*

* Funktion-Deklaration
      DEFINE("FAC(N)")

* springe zum Start
      :(START)

* Funktions-Implementierung
FAC   FAC = 1
      LE(N, 1)     :S(RETURN)
      FAC = N * FAC(N - 1)
      :(RETURN)


START
      OUTPUT = FAC(6)
END
Calculates the factorial. Results 720.


 Hello World   SNOBOL4   Michael Neumann
*
* die Einrückung ist wichtig!!!
*
      OUTPUT = 'Hello World'
END
Prints "Hello World" onto the screen.


 Squares   SNOBOL4   Michael Neumann
      I = 1
      TXT = ''

LOOP
* wenn I > 10 dann springe nach DONE
      GT(I, 10)       :S(DONE)
      TXT = TXT (I ** 2) ' '
      I = I + 1       :(LOOP)
DONE  OUTPUT = TXT
END
Outputs the squares from 1 to 10.






 SQL    up
 
  Description: SQL stands for Structured Query Language.


 Hello World   Michael Neumann
SELECT 'Hello World'
Prints "Hello World" onto the screen.


 Hello World   Oracle SQL   Michael Neumann
SELECT 'Hello World' FROM dual;
Prints "Hello World" onto the screen.






 Superbase    up
 
 


 Hello World   Marco Puchinger
' Hello World in Superbase

? "Hello, World!"
Prints "Hello World" onto the screen.






 Tcl    up
 
 


 Hello World   Michael Neumann
puts "Hello World"
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
set i 1
while {$i <= 10} {puts [expr $i*$i];set i [expr $i+1]}
Outputs the squares from 1 to 10.


 Substitution   Michael Neumann
set a 3
set b 5
puts "$a + $b = [expr $a + $b]"
Prints 3 + 5 = 8 onto the screen.


 Hello World   Tcl/Tk   Michael Neumann
button .hello -text "Hello World" -command {destroy .}
pack .hello
Prints "Hello World" onto the screen.






 TI-83 Graphing Calculator    up
 
 


 Eulersche Number   Thomas John LaGatta
:Disp e
Calculates the eulersche-number (e=2.71828).


 Hello World   Thomas John LaGatta
:Disp "Hello World"
Prints "Hello World" onto the screen.


 Squares   Thomas John LaGatta
:For(X,1,10)
:Disp X²
:End
Outputs the squares from 1 to 10.






 TOM    up http://www.gerbil.org/tom
  similar languages: C   C#   C++   C-Talk   D   Cilk   Java   Objective-C   Pike  
  Description: TOM is a modern, object-oriented programming language. In TOM you can extend an existing class (e.g. overwrite a method) without having the sourcecode and without new compilation. TOM's method-invokations respectively their parameter are similar to those of Smalltalk, because you can give them names. Furthermore, TOM is garbage-collected, has pre- and post-conditions, multiple-inheritance and a C-like syntax.


 Hello World   Michael Neumann
/* Hello World in TOM */

implementation class HelloWorld

   int main Array argv
   {
      [[[stdio out] print "Hello World"] nl];
      return 0;
   }

end;


implementation instance HelloWorld end;
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
implementation class Squares

   int main Array argv
   {
      for( int i=1; i<=10; ++i ) [[stdio out] print (i*i, " ")];
      return 0;
   }
   
end;


implementation instance Squares end;
Outputs the squares from 1 to 10.






 Turing    up http://www.holtsoft.com/turing/introduction.html
 
  Description: Turing is a general purpose programming language designed for the convenient development of reliable, efficient programs. A descendant of Pascal, Turing is specifically designed to be easy to learn, to have a concise and expressive syntax, graceful and effective treatment of errors, effective control of program complexity, a mathematically precise language definition, and a small, fast implementation. It is particularly well suited to support computer science education.


  Factorial   James R. Cordy
function fac (n : int)
    if n > 1 then
        result n * fac (n - 1)
    else
        result 1
    end if
end fac

put fac (6)
Calculates the factorial. Results 720.


 Hello World   James R. Cordy
put "Hello World"
Prints "Hello World" onto the screen.


 Squares   James R. Cordy
for i : 1 .. 10
    put i * i
end for
Outputs the squares from 1 to 10.






 TXL    up http://www.txl.ca/allabouttxl.html
 
  Description: TXL is a pure functional programming language and rapid prototyping system specifically designed to support source transformation tasks such as computer software analysis and reengineering. The paradigm involves transforming input to output by application of a rooted set of source transformation rules.


 Bubblesort   Jim Cordy
% Bubblesort any sequence of numbers

% Required description of input and output forms - a sequence of numbers
define program
    [repeat number]
end define

% Transform any sequence to a sorted sequence by replacing
% any unordered pair of adjacent numbers by an ordered pair.
% The rule stops when there are no unordered pairs left. 
rule main
    replace [repeat number]
        N1 [number] N2 [number] Rest [repeat number]
    where
        N1 [> N2]
    by
      N2 N1 Rest
end rule
Bubblesort


 Hello World   Jim Cordy
% Required description of input forms - in this case 
% any input will do
define program
    [repeat token]
end define

% Main transformation rule - whatever the input,
% transform it into Hello World
function main
    replace [program]
        _ [program]
    by
        "Hello World"
end function
Prints "Hello World" onto the screen.


 Squares   Jim Cordy
% Transform any number to its square

% Required description of input and output forms - both simply a number
define program
    [number]
end define

% Transform the input number to its square
function main
    replace [program]
        N [number]
    by
      N [* N]
end function
Outputs the square of its input.






 UFO    up
 
 


 Hello World   Michael Neumann
main : String is
   "Hello World\n"
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
**
** 
**

main : String is
{
   squares = for i in [1 to 10] do
             return all i*i
             od;

   output  = initially txt = ""
             for i in squares do
                new txt = txt ++ print(i) ++ " "
             return txt
             od;

   return output ++ "\n"
}
Outputs the squares from 1 to 10.






 UML (Unified Modeling Language)    up
 
 


 OO - Shape, Circle, Rectangle (1)   Michael Neumann

Diagram made with Dia.


 OO - Shape, Circle, Rectangle (2)   Michael Neumann

Diagram made with Fujaba.






 VHDL    up
 
  Description: VHDL = VLSI (Very Large Scale Integrity) Hardware Description Language.


 Hello World   Roger Daniel Pease
ENTITY helloworld IS
END helloworld;

ARCHITECTURE bhv OF helloworld IS

BEGIN

ASSERT FALSE
REPORT "HELLO WORLD"
SEVERITY NOTE;

END bhv;
Prints "Hello World" onto the screen.






 Vim    up http://www.vim.org
 
  Description: Vim is a Vi-like programmable text-editor.


 Hello World   Michael Neumann
:"Hello World in Vim
:echo "Hello World"  
Prints "Hello World" onto the screen.


 Squares   Michael Neumann
:func Squares(from, to)
:  let n = a:from 
:  let r = ""
:
:  while n <= a:to
:    let r = r . (n*n) . " "
:    let n = n + 1
:  endwhile
:
:  return r
:endfunc

:"Nun die Funktion aufrufen
:echo Squares(1, 10)
Outputs the squares from 1 to 10.






 WebL    up
 
 


  Factorial   Michael Neumann
/*
 * Calculates the factorial
 */

var fac = fun(n)
   if n==1 or n==0 then
      1
   else
      n*fac(n-1)
   end
end;

PrintLn( fac(6) );
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
// Hello World in WebL

PrintLn("Hello World");
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
every i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] do
   Print(i*i, " ")
end
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
var i=1;
repeat Print(i*i, " "); i=i+1 until i>10 end
Outputs the squares from 1 to 10.






 WML (Wireless Markup Language)    up
  similar languages: HTML   SGML   XHTML   XML  
 


 Hello World   Michael Neumann
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<!-- Hello World in WML -->
<wml>
   <card id="Hello_World" title="Hello World">
      <p>Hello World</p>
   </card>
</wml>
Prints "Hello World" onto the screen.






 XPL0    up http://www.idcomm.com/personal/lorenblaney/
 
  Description: XPL0 (zero) is similar to Pascal. It was created in the mid 70's by P.J.R. Boyle and the 6502 Group. It is free under the terms of the GNU General Public License.


 Hello World   Loren Blaney
code Text=12;
Text(0, "Hello World");
Prints "Hello World" onto the screen.


 Squares   Loren Blaney
code Crlf=9, Intout=11;
int I;

for I:= 1, 10 do
    begin
    Intout(0, I*I);
    Crlf(0);
    end;

Outputs the squares from 1 to 10.






 Yacas    up
 
 


 Factorial (1)   Michael Neumann
6!;
Calculates the factorial. Results 720.


 Factorial (2)   Michael Neumann
IsPosInt(_n) <-- IsInteger(n) and n > 0;

fac(0) <-- 1;
fac(n_IsPosInt) <-- n * fac(n-1);

fac(6);
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
WriteString("Hello World");
Prints "Hello World" onto the screen.






 YAFL    up
  similar languages: Modula   Oberon   Obliq   Leda   Pascal   Phantom   PL/0   PL/0E  
  Description: YAFL is a very clearly structured and modularized, object-oriented programming-language. It inherits features from Algol, Eiffel, Modula, Ada, C and C++.


 Hello World   Michael Neumann
DEFINITION MODULE HelloWorld;

   CLASS HelloClass;
      METHOD CREATE;
      METHOD Main;
   END HelloClass;
   
END HelloWorld;


IMPLEMENTATION MODULE HelloWorld;
   FROM Streams IMPORT StdOut;
 
   CLASS HelloClass;
            
      METHOD CREATE;         
         BEGIN
         -- wird aufgerufen um das Objekt zu initialisieren
         Main;
         END;
         
      METHOD Main;
         BEGIN
         StdOut.WriteLine ("Hello World");
         END Main;
         
   END HelloClass;
   
END HelloWorld;
Prints "Hello World" onto the screen.






 Yoix    up http://www.research.att.com/sw/tools/yoix/
 
  Description: Yoix is a scripting language and interpreter written in pure Java. The language itself resembles a bit of both Java's and/or C's syntax, but is much more usable for scripting.


  Factorial   Michael Neumann
/* 
 * Calculate the factorial
 */

fac(n) {
   if (n > 1) return n * fac(n-1);
   else return 1;
} 

yoix.stdio.printf("fac(6) = %d\n", fac(6));
Calculates the factorial. Results 720.


 Hello World (1)   Michael Neumann
// Hello World in Yoix

import yoix.stdio.*;

printf("Hello World\n");
Prints "Hello World" onto the screen.


 Hello World (2)   Michael Neumann
stdout.nextline = "Hello World"; 
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
int    i;
String str = "";
   
for (i = 1; i <= 10; i++) {
  str += toString(i*i) + " ";
}

yoix.stdio.printf(str + "\n");
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
int   i;
Array arr = { 1,2,3,4,5,6,7,8,9,10 };
     
for (i = 0; i < arr@length; i++) {
  a[i] *= a[i];
}

stdout.nextline = toString(a);
Outputs the squares from 1 to 10.






 Yorick    up
 
  Description: Yorick is a C-like, interpreted language, which is mainly used in physics because of the many build-in, specialized functions.


 Eulersche Number   Michael Neumann
// Fakultät
func fac(n) {
   if(n>1) return n*fac(n-1)
   else return 1
}

arr= span(0,9,10)   // 10 Werte von 0-9

for(i=1; i<=numberof(arr); i++) {
   arr(i) = fac(arr(i))
}

print, sum(1/arr)
Calculates the eulersche-number (e=2.71828).


  Factorial   Michael Neumann
func fac(n) {
   if(n>1) return n*fac(n-1)
   else return 1
}

print, fac(6)
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
// Hello World in Yorick

write, "Hello World\n"
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
/*
  indgen(n) erzeugt ein Array von 1-n
*/

print, indgen(10)^2
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
for(i=1; i<=10; i++)
{
   print, i*i
}
Outputs the squares from 1 to 10.







Copyright © 2000, 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)