Category:ALGOL 68
This programming language may be used to instruct a computer to perform a task.
Parameter passing methods:  By reference, By value 

Type safety:  Safe 
Type strength:  Soft, weak, meek, firm and strong  depending on context. 
Type compatibility:  Structural 
Type expression:  Explicit 
Type checking:  Dynamic, Static 
See Also: 
If you know ALGOL 68, please write code for some of the tasks not implemented in ALGOL 68.
ALGOL 68 (short for ALGOrithmic Language 1968) is an imperative computer programming language that was conceived as a successor to the ALGOL 60 programming language, designed with the goal of a much wider scope of application and more rigorously defined syntax and semantics.
The main aims and principles of design of ALGOL 68:
 Completeness and clarity of design,
 Orthogonal design,
 Security,
 Efficiency:
 Static mode checking,
 Modeindependent parsing,
 Independent compilation,
 Loop optimization,
 Representations  in minimal & larger character sets.
Contents
Execute an ALGOL 68 program online[edit]
Grammar[edit]
The grammar for ALGOL 68 is officially in the two level, Van Wijngaarden grammar but a subset has been done in the one level Backus–Naur Form:
 Van Wijngaarden grammar: [1]
 Backus–Naur Form/Yacc: [2]
 Syntax Chart (Size 516.6 kB  File type application/pdf)
Resources[edit]
 ALGOL BULLETIN  March 1959 to August 1988, in 52 issues[3]
 Algol68 mailinglist  December 2008  algol68user AT lists.sourceforge.net[4]
 Algol68 group at linked: [5]  includes various famous compiler composers.
FYI: There are two online manual pages:
Or  if you prefer a hardcopy  you can try and pick up a hard cover manual like "Informal Introduction to Algol 68"  by C. H. Lindsey & S. V. Vander Meulen. Be sure to get the 1977 edition:
 www.amazon.com  Aboout $119
 barnesandnoble.com  about $40
IItA68 is a beautiful book, and makes great "bedtime" reading... Highly recommended!
 NEW: softwarepreservation.org has an online IItA68 PDF ready for download.
Editor modes:
 Emacs mode for Algol 68 supporting syntax highlighting and contextsensitive indentation.
 Vim script providing support for syntax highlighting.
 NEW: GeSHi syntax highlighting
Status[edit]
 20th December 1968  ALGOL 68's Final Report was ratified by UNESCO's IFIP working group 2.1 in Munich.
 20th December 2008  Zig Zag  the 100th ALGOL 68 code contribution on rosettacode.org!
 Happy 40th Birthday ALGOL 68,
 AND 50th Birthday ALGOL 58.
 23rd August 2009  algol68g1.18.09h released
 20th December 2009  Happy 51st/41st Birthdays with Hamming numbers  the 200th ALGOL 68 code contribution on rosettacode.org!
 This time code was by Marcel van der Veer, author of Algol 68 Genie
 25th October 2011  Jejones3141 added Soundex  the 300th ALGOL 68 code specimen.
Revisions[edit]
 Mar. 1968: Draft Report on the Algorithmic Language ALGOL 68  Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck and C.H.A. Koster.
 Oct. 1968: Penultimate Draft Report on the Algorithmic Language ALGOL 68  Chapters 19  Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck and C.H.A. Koster.
 Dec. 1968: Report on the Algorithmic Language ALGOL 68  Offprint from Numerische Mathematik, 14, 79218 (1969); SpringerVerlag.  Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck and C.H.A. Koster.
 Sep 1973: Revised Report on the Algorithmic Language Algol 68  SpringerVerlag 1976  Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck, C.H.A. Koster, M. Sintzoff, C.H. Lindsey, L.G.L.T. Meertens and R.G. Fisker.
Code samples[edit]
Most of the code samples provided here have a leading main:(
and a matching )
at the end. These are not actually required in the language, but are included so as to highlight that the code sample is complete, and works with (at least) ALGOL 68G unmodified.
On some compilers, it may be necessary to include appropriate "job cards" or precludes in order for the programs to compile successfully. Hopefully not too much else is required. Examples:
Brief Algol68  Algol68 as in rosettacode  Actual ELLA Algol 68RS code 
print(("Hello, world!",new line)) 
main:( print(("Hello, world!",new line)) ) 
PROGRAM helloworld CONTEXT VOID USE standard BEGIN print(("Hello, world!", new line)) END FINISH 
Example of different program representations[edit]
At the time when ALGOL 68 was defined some predominant computers had 24 or 36 bit words, with 6 bit character sets. Hence it was desirable that ALGOL 68 should be able to run on machines with only uppercase. The official spec provided for different representations of the same program. Quote stropping (enclosing the bold words in single quotes) and Point stropping (preceeding the bold words with a dot) were used. A variant of Point stropping called RES stropping was also defined. In RES stropping some languagedefined bold words are not preceded by a dot. A pragmatic comment may have been required to indicate which stropping convention was to be used, as in some of the examples below. Upper stropping (representing the bold words by upper case and nonbold words in lower case) was introduced by Algol 68R. Upper stropping is used by Algol 68RS and is one of the options for Algol 68G. Rutgers ALGOL 68 uses quote stropping. Most of the samples on Rosetta Code use Upper stropping. Example:
Algol68 as typically published
¢ bold/underline typeface ¢ mode xint = int; xint sum sq:=0; for i while sum sq≠70×70 do sum sq+:=i↑2 od 
quote stropping (similar to wiki)
'pr' quote 'pr' 'mode' 'xint' = 'int'; 'xint' sum sq:=0; 'for' i 'while' sum sq≠70×70 'do' sum sq+:=i↑2 'od' 
7bit/ascii compiler
.PR UPPER .PR MODE XINT = INT; XINT sum sq:=0; FOR i WHILE sum sq/=70*70 DO sum sq+:=i**2 OD 
6bits/byte compiler
.PR POINT .PR .MODE .XINT = .INT; .XINT SUM SQ:=0; .FOR I .WHILE SUM SQ .NE 70*70 .DO SUM SQ .PLUSAB I .UP 2 .OD 
RES stropping
.PR RES .PR mode .xint = int; .xint sum sq:=0; for i while sum sq≠70×70 do sum sq+:=i↑2 od 
Upper stropping
# upper case = bold # MODE XINT = INT; XINT sum sq:=0; FOR i WHILE sum sq /= 70*70 DO sum sq PLUSAB i UP 2 OD 
Coercion (casting)[edit]
ALGOL 68 has a hierarchy of contexts which determine which kind of coercions are available at a particular point in the program. These contexts are:
N a 
Context location  Coercions available in this context  Coercion examples  

Soft  Meek  Weak  Firm  Strong  
S t 
Right hand side of:
Also:

deproc eduring  all soft then weak deref erencing  all weak then deref erencing  all meek then uniting  all firm then widening, rowing and voiding 
Widening occurs if there is no loss of precision. For example: An INT will be coerced to a REAL, and a REAL will be coerced to a LONG REAL. But not viceversa. Examples: INT to LONG INT A variable can also be coerced (rowed) to an array of length 1. For example: INT to [1]INTetc 
F i 

Example:
UNION(INT,REAL) var := 1  
M e 
IF ~ THEN ... FIand FROM ~ BY ~ TO ~ WHILE ~ DO ... OD etc

Examples:
REF REF BOOL to BOOL  
W e 

Examples:
REF BOOL to REF BOOL  
S o 
The LHS of assignments, as "~" in: ~ := ... 
Example:

For more details about Primaries and Secondaries refer to Operator precedence.
See also[edit]
Code Specimen[edit]
Subcategories
This category has the following 3 subcategories, out of 3 total.
Pages in category "ALGOL 68"
The following 432 pages are in this category, out of 432 total.
A
 A+B
 ABC Problem
 Accumulator factory
 Ackermann function
 Address of a variable
 AKS test for primes
 Algol 68
 Align columns
 Almost prime
 Amb
 Anonymous recursion
 Apply a callback to an array
 Arbitraryprecision integers (included)
 Arithmetic evaluation
 Arithmeticgeometric mean
 Arithmetic/Complex
 Arithmetic/Integer
 Arithmetic/Rational
 Array concatenation
 Array length
 Arrays
 Assertions
 Associative array/Creation
 Averages/Arithmetic mean
 Averages/Median
 Averages/Pythagorean means
 Averages/Root mean square
 Averages/Simple moving average
B
C
 Caesar cipher
 Calendar
 Calendar  for "REAL" programmers
 Call a foreignlanguage function
 Call a function
 Casesensitivity of identifiers
 Catamorphism
 Character codes
 Cholesky decomposition
 Classes
 Closures/Value capture
 Combinations
 Combinations and permutations
 Comma quibbling
 Commandline arguments
 Comments
 Compare a list of strings
 Compound data type
 Concurrent computing
 Conditional structures
 Constrained random points on a circle
 Continued fraction
 Conway's Game of Life
 Copy a string
 Count in factors
 Count in octal
 Count occurrences of a substring
 Count the coins
 CRC32
 Create a file
 Create a twodimensional array at runtime
 Create an HTML table
 CSV data manipulation
 CSV to HTML translation
 Currying
D
 Date format
 Day of the week
 Define a primitive data type
 Delegates
 Delete a file
 Detect division by zero
 Determine if a string is numeric
 Digital root
 Digital root/Multiplicative digital root
 Dijkstra's algorithm
 Dinesman's multipledwelling problem
 Dot product
 Doublylinked list/Definition
 Doublylinked list/Element definition
 Doublylinked list/Element insertion
 Doublylinked list/Traversal
 Dragon curve
E
 Elementwise operations
 Empty program
 Empty string
 Enforced immutability
 Entropy
 Enumerations
 Environment variables
 Equilibrium index
 Ethiopian multiplication
 Euler method
 Euler's sum of powers conjecture
 Evaluate binomial coefficients
 Even or odd
 Evolutionary algorithm
 Exceptions
 Exceptions/Catch an exception thrown in a nested call
 Execute a system command
 Execute Brain****
 Execute HQ9+
 Exponentiation operator
 Exponentiation order
 Extract file extension
F
 Factorial
 Factors of a Mersenne number
 Factors of an integer
 Fast Fourier transform
 Fibonacci sequence
 Fibonacci word
 File input/output
 File modification time
 File size
 Filter
 Find common directory path
 Find first and last set bit of a long integer
 Find limit of recursion
 Firstclass functions
 Firstclass functions/Use numbers analogously
 Five weekends
 FizzBuzz
 Flatten a list
 Flowcontrol structures
 Floyd's triangle
 Forest fire
 Fork
 Formatted numeric output
 Forward difference
 Fractran
 Function composition
 Function definition
 Function prototype
G
 Gamma function
 Gaussian elimination
 Generalised floating point addition
 Generalised floating point multiplication
 Generate lower case ASCII alphabet
 Generator/Exponential
 Generic swap
 Gray code
 Greatest common divisor
 Greatest element of a list
 Greatest subsequential sum
 Guess the number
 Guess the number/With feedback
H
 Hailstone sequence
 Hamming numbers
 Happy numbers
 Harshad or Niven series
 Haversine formula
 Hello world/Graphical
 Hello world/Line printer
 Hello world/Newbie
 Hello world/Standard error
 Hello world/Text
 Here document
 Heronian triangles
 Hickerson series of almost integers
 Higherorder functions
 Hofstadter Q sequence
 HofstadterConway $10,000 sequence
 Holidays related to Easter
 Horizontal sundial calculations
 Horner's rule for polynomial evaluation
 Host introspection
 Hostname
 HTTP
I
L
 Leap year
 Least common multiple
 Letter frequency
 Linear congruential generator
 List comprehensions
 Literals/Integer
 Literals/String
 Logical operations
 Long multiplication
 Longest common prefix
 Longest common subsequence
 Longest string challenge
 Lookandsay sequence
 Loop over multiple arrays simultaneously
 Loops/Break
 Loops/Continue
 Loops/Dowhile
 Loops/Downward for
 Loops/For
 Loops/For with a specified step
 Loops/Foreach
 Loops/Infinite
 Loops/N plus one half
 Loops/Nested
 Loops/While
 LucasLehmer test
 Luhn test of credit card numbers
M
 Mad Libs
 Magic squares of odd order
 Man or boy test
 Mandelbrot set
 Map range
 Matrix multiplication
 Matrix transposition
 Matrixexponentiation operator
 Maximum triangle path sum
 MD5
 Memory allocation
 Memory layout of a data structure
 Menu
 Metaprogramming
 Metered concurrency
 Middle three digits
 Miller–Rabin primality test
 Modular arithmetic
 Modular exponentiation
 Modular inverse
 Monte Carlo methods
 Monty Hall problem
 Movetofront algorithm
 Multidimensional array
 Multifactorial
 Multiple distinct objects
 Multiplication tables
 Multiplicative order
 Mutual recursion
N
O
P
 Palindrome detection
 Pangram checker
 Parsing/RPN calculator algorithm
 Parsing/RPN to infix conversion
 Partial function application
 Pascal's triangle
 Pascal's triangle/Puzzle
 Perfect numbers
 Permutations
 Permutations with repetitions
 Phrase reversals
 Pi
 Pick random element
 Playing cards
 Plot coordinate pairs
 Pointers and references
 Polymorphism
 Polynomial regression
 Power set
 Pragmatic directives
 Price fraction
 Primality by trial division
 Prime decomposition
 Probabilistic choice
 Program name
 Program termination
R
 Random number generator (included)
 Random numbers
 Range expansion
 Range extraction
 Read a file line by line
 Read a specific line from a file
 Read entire file
 Real constants and functions
 Reduced row echelon form
 Regular expressions
 Rename a file
 Repstring
 Repeat
 Repeat a string
 Return multiple values
 Reverse a string
 Rockpaperscissors
 Roman numerals/Decode
 Roman numerals/Encode
 Roots of a function
 Roots of a quadratic function
 Roots of unity
 Rosetta Code/Rank languages by popularity
 Rot13
 RSA code
 Runlength encoding
 RungeKutta method
 Runtime evaluation
 Runtime evaluation/In an environment
S
 Scope modifiers
 Search a list
 SEDOLs
 Selfdescribing numbers
 Sequence of nonsquares
 Sevensided dice from fivesided dice
 Shell oneliner
 Shortcircuit evaluation
 Sierpinski carpet
 Sierpinski triangle
 Sieve of Eratosthenes
 Singlylinked list/Element definition
 Singlylinked list/Element insertion
 Singlylinked list/Traversal
 Sleep
 Sort an array of composite structures
 Sort an integer array
 Sorting algorithms/Bogosort
 Sorting algorithms/Bubble sort
 Sorting algorithms/Cocktail sort
 Sorting algorithms/Counting sort
 Sorting algorithms/Gnome sort
 Sorting algorithms/Heapsort
 Sorting algorithms/Insertion sort
 Sorting algorithms/Merge sort
 Sorting algorithms/Pancake sort
 Sorting algorithms/Quicksort
 Sorting algorithms/Radix sort
 Sorting algorithms/Selection sort
 Sorting algorithms/Shell sort
 Soundex
 Special characters
 Special variables
 Spiral matrix
 Stack
 Stairclimbing puzzle
 Standard deviation
 Straddling checkerboard
 String append
 String case
 String comparison
 String concatenation
 String interpolation (included)
 String length
 String matching
 String prepend
 Strip a set of characters from a string
 Strip comments from a string
 Strip control codes and extended characters from a string
 Strip whitespace from a string/Top and tail
 Substring
 Substring/Top and tail
 Sudoku
 Sum and product of an array
 Sum digits of an integer
 Sum of a series
 Sum of squares
 Synchronous concurrency
 System time
T
U
W
 Parameter passing/By reference
 Parameter passing/By value
 Typing/Safe
 Typing/Soft, weak, meek, firm and strong  depending on context.
 Typing/Compatibility/Structural
 Typing/Expression/Explicit
 Typing/Checking/Dynamic
 Typing/Checking/Static
 Programming Languages
 Programming paradigm/Concurrent
 Programming paradigm/Imperative