Colambda

From Esolang
Jump to: navigation, search

Colambda is an esoteric programming language designed by User:Zzo38 in 2010 as a sort of coprocessor for Unlambda programming. When Colambda must be loaded, it must be a program file containing one or more Unlambda programs which can be numbered, and one or more files of arbitrary data, which can be numbered. One main Unlambda file is numbered zero, and is the file when starting the program. You can run multiple threads, and there is a storage of INTERCAL registers shared with all threads. Each thread of Unlambda codes has its own memory and input/output.

The Unlambda program must send commands as output, which are processed by Colambda, and receives input for the results of commands.

These are commands that can be used:

  • 0 - output bit zero
  • 1 - output bit one
  • ? - receive character of input as eight bits 0 and 1 (or . if EOF)
  • ~dxy - read x and y and use select operator, stored in d
  • $dxy - read x and y and use interleave operator, stored in d
  • ?d - read d and use unary XOR, stored in d
  • &d - read d and use unary AND, stored in d
  • Vd - read d and use unary OR, stored in d
  • Ndxy - read x and y and use NAND operator, stored in d
  • _dx - read x and store in d
  • *x - receive value of x
  • Sd - stash x
  • Rd - retrieve x
  • id - ignore x
  • rd - remember x
  • ox - send x to output
  • ydx - get binary data from stream x and store in array d, first reallocating array to correct size (data stored 8 bits in each cell)
  • Ydx - same as above but as many bits as possible in each cell of the array
  • + - increment value of register :1
  • - - decrement value of register :1
  • Bx - get binary data from stream x send to Unlambda program as 0 and 1
  • bx - get binary data from stream x send to Unlambda program as bytes characters
  • ad - reallocate an array, using values of .1 .2 .3 for number of elements each dimension, if one of these is zero, that is the end of the dimensions
  • =dx - create subprogram thread of program numbered x, and store the subprogram thread ID number in d
  • !x - switch to subprogram x
  • Mx - make Colambda execute commands from characters of byte stream x, until stream is end
  • mx - send characters of stream x to output

Source/destination operands can use a character followed by the 0 and 1 for sixteen bits:

  • # - literal number value
  • . - 16-bit register
  • : - 32-bit register
  • , - 16-bit array (uses .1 .2 and so on for subscript numbers)
  • ; - 32-bit array (uses .1 .2 and so on for subscript numbers)
  • / - same as previous operand (no bits)
  • P - number of thread switched out of (no bits)
  • p - number of current thread (no bits)

As well as 0 and 1 for bits, you can also use these abbreviations:

  • q - 0000
  • Q - 00000000
  • k - 1111
  • K - 11111111
  • d - 00000001
  • j - 100