XPL0
'''XPL0''' is essentially a cross between Pascal and C. It looks somewhat like Pascal but works more like C. It was originally created in 1976 by Peter J. R. Boyle, who designed it to run on a 6502 microprocessor as an alternative to BASIC, which was the dominant language for personal computers at the time. XPL0 is based on PL/0, an example compiler in the book ''Algorithms + Data Structures = Programs'' by Niklaus Wirth. The first XPL0 compiler was written in ALGOL, which was then used to create a compiler written in XPL0's syntax.
XPL0 has been implemented on more than a dozen processors, but it's currently maintained for IBM-type PCs. Programs run under DOS and under versions of Windows that can still run DOS apps. Free, open-source versions of the compilers (interpreted, assembly-code compiled, and optimizing) are available from the official website: xpl0.org (archived copy). The 32-bit version of the compiler, XPLPX, was used for all these Rosetta Code tasks.
Here's how the traditional Hello World program is coded:
code Text=12;
Text(0, "Hello World!")
Text is a built-in routine, called an ''intrinsic'', that outputs a string of characters. The zero (0) tells where to send the string. In this case it is sent to the display screen; but it could just as easily be sent to a printer, a file, or out a serial port by using a different number.
All names must be declared before they can be used. The command word ''code'' associates the name Text to the built-in routine number 12, which outputs strings. There are about 80 of these built-in routines that provide capabilities such as input and output, graphics, and trig functions.
Tasks
- 100 doors
- 2048
- A+B
- Ackermann function
- Address of a variable
- Animate a pendulum
- Animation
- Anonymous recursion
- Arithmetic-geometric mean
- Arithmetic/Complex
- Arithmetic/Integer
- Arrays
- Assertions
- Associative array/Creation
- Associative array/Iteration
- Averages/Arithmetic mean
- Averages/Mean angle
- Averages/Mean time of day
- Averages/Pythagorean means
- Averages/Root mean square
- Balanced brackets
- Best shuffle
- Binary digits
- Bitmap
- Bitmap/Bézier curves/Cubic
- Bitmap/Bézier curves/Quadratic
- Bitmap/Flood fill
- Bitmap/Midpoint circle algorithm
- Bitmap/Read a PPM file
- Bitmap/Write a PPM file
- Boolean values
- Bresenham's Line Algorithm
- Brownian tree
- CRC-32
- Caesar cipher
- Calendar
- Case-sensitivity of identifiers
- Catalan numbers
- Character codes
- Check Machin-like formulas
- Circles of given radius through two points
- Closest-pair problem
- Color of a screen pixel
- Colour bars/Display
- Colour pinstripe/Display
- Combinations
- Combinations with repetitions
- Comma quibbling
- Comments
- Compile-time calculation
- Conditional structures
- Constrained random points on a circle
- Continued fraction
- Continued fraction/Arithmetic/Construct from rational number
- Copy a string
- Count in factors
- Count in octal
- Count occurrences of a substring
- Create a two-dimensional array at runtime
- Cumulative standard deviation
- Date format
- Day of the week
- Detect division by zero
- Digital root
- Dinesman's multiple-dwelling problem
- Dot product
- Dragon curve
- Draw a cuboid
- Draw a sphere
- Empty program
- Empty string
- Enforced immutability
- Entropy
- Enumerations
- Environment variables
- Equilibrium index
- Ethiopian multiplication
- Euler method
- Evaluate binomial coefficients
- Even or odd
- Evolutionary algorithm
- Exponentiation operator
- Factorial
- Factors of an integer
- Fibonacci n-step number sequences
- Filter
- Find the missing permutation
- Five weekends
- FizzBuzz
- Floyd's triangle
- Four bit adder
- Fractal tree
- Function definition
- Galton box animation
- Generator/Exponential
- Generic swap
- Globally replace text in several files
- Gray code
- Greatest common divisor
- Greatest element of a list
- Greatest subsequential sum
- Greyscale bars/Display
- Guess the number
- Guess the number/With feedback
- Guess the number/With feedback (player)
- Hailstone sequence
- Happy numbers
- Harshad or Niven series
- Haversine formula
- Hello world!
- Hello world/Line printer
- Hello world/Newline omission
- Hello world/Standard error
- Hello world/Text
- Here document
- Hofstadter Q sequence
- Honeycombs
- Horizontal sundial calculations
- Horner's rule for polynomial evaluation
- Host introspection
- Identity matrix
- Image noise
- Include a file
- Increment a numerical string
- Integer comparison
- Integer sequence
- Josephus problem
- K-means++ clustering
- Kaprekar numbers
- Keyboard input/Flush the keyboard buffer
- Keyboard input/Keypress check
- Keyboard input/Obtain a Y or N response
- Knapsack problem/0-1
- Knapsack problem/Continuous
- Knight's tour
- Langton's ant
- Last Friday of each month
- Leap year
- Least common multiple
- Letter frequency
- Linear congruential generator
- Literals/Floating point
- Literals/Integer
- Literals/String
- Logical operations
- Long multiplication
- Loop over multiple arrays simultaneously
- Loops/Break
- Loops/Continue
- Loops/Do-while
- Loops/Downward for
- Loops/For
- Loops/For with a specified step
- Loops/Foreach
- Loops/Infinite
- Loops/N plus one half
- Loops/Nested
- Loops/While
- Mandelbrot set
- Map range
- Matrix multiplication
- Maze generation
- Memory allocation
- Menu
- Middle three digits
- Modular inverse
- Monte Carlo methods
- Monty Hall problem
- Morse code
- Multifactorial
- Multiple distinct objects
- Multiplication tables
- Munching squares
- Musical scale
- Mutual recursion
- N-queens problem
- Non-decimal radices/Convert
- Non-decimal radices/Input
- Non-decimal radices/Output
- Nth root
- Number names
- Number reversal game
- Numerical integration
- One-dimensional cellular automata
- Operator precedence
- Palindrome detection
- Pangram checker
- Pascal's triangle
- Perfect numbers
- Permutations
- Permutations by swapping
- Pick random element
- Pig the dice game
- Pinstripe/Display
- Plot coordinate pairs
- Pointers and references
- Price fraction
- Primality by trial division
- Probabilistic choice
- Program termination
- Queue/Definition
- Queue/Usage
- Random number generator (device)
- Random number generator (included)
- Range expansion
- Rate counter
- Read a specific line from a file
- Real constants and functions
- Remove duplicate elements
- Repeat a string
- Resistor mesh
- Return multiple values
- Reverse a string
- Roman numerals/Decode
- Rot-13
- Run-length encoding
- Search a list
- Self-describing numbers
- Semordnilap
- Sierpinski carpet
- Sierpinski triangle
- Sierpinski triangle/Graphical
- Sieve of Eratosthenes
- Simple windowed application
- Singly-linked list/Element definition
- Singly-linked list/Traversal
- Solve the no connection puzzle
- Sort an array of composite structures
- Sort an integer array
- Sorting algorithms/Bead sort
- Sorting algorithms/Bogosort
- Sorting algorithms/Bubble sort
- Sorting algorithms/Cocktail sort
- Sorting algorithms/Counting sort
- Sorting algorithms/Gnome sort
- Sorting algorithms/Insertion sort
- Sorting algorithms/Merge sort
- Sorting algorithms/Quicksort
- Sorting algorithms/Selection sort
- Sorting algorithms/Shell sort
- Sorting algorithms/Stooge sort
- Soundex
- Spiral matrix
- Stack
- Stair-climbing puzzle
- String case
- String concatenation
- String length
- String matching
- Strip control codes and extended characters from a string
- Strip whitespace from a string/Top and tail
- Substring/Top and tail
- Sudoku
- Sum and product of an array
- Sum digits of an integer
- Sum multiples of 3 and 5
- Sum of a series
- Sum of squares
- System time
- Temperature conversion
- Terminal control/Clear the screen
- Terminal control/Coloured text
- Terminal control/Cursor movement
- Terminal control/Cursor positioning
- Terminal control/Dimensions
- Terminal control/Display an extended character
- Terminal control/Hiding the cursor
- Terminal control/Inverse video
- Terminal control/Positional read
- Terminal control/Preserve screen
- Terminal control/Ringing the terminal bell
- Tic-tac-toe
- Time a function
- Tokenize a string
- Topswops
- Trabb Pardo–Knuth algorithm
- Trigonometric functions
- Truncatable primes
- URL decoding
- URL encoding
- Van der Corput sequence
- Variable size/Get
- Variable size/Set
- Variables
- Variadic function
- Vector products
- Video display modes
- Vigenère cipher
- Wireworld
- XML/Input
- XML/Output
- Yin and yang
- Zeckendorf number representation
- Zig-zag matrix