Deadfish

From Esolang
Jump to: navigation, search

Deadfish is a very odd interpreted programming language created by Jonathan Todd Skinner. It was released under public domain and was originally programmed in C, but now it has been since ported to many other programming languages(see below). Deadfish has a way to output things but it has no way to input them! It has only a few commands, only four in total. It is also case-sensitive, and can deal only with integer values when adding or subtracting, however once squared this number increases greatly! You can have several commands per line, at least in the C implementation. Errors are not acknowledged the shell simply adds a newline character! Anything that is not a command is not accepted by the interpreter. As you've probably assumed deadfish was created in less then a hour, and can be very useful in creating highly interactive programs[sic].

Contents

[edit] Commands

  Increment Decrement Square Output
Standard Deadfish i d s o
XKCD variation x d k c

[edit] Why deadfish

Deadfish started out as a subset of HQ9+, as all it would do would be to print out hello world and give an iou depending on how many times the command 9 was entered for how many 99 bottles of beer programs it owed the programmer. Deadfish was originally going to be called fishheads as programming in this language is like eating raw fish heads. However, due to the limiting features of the language, programming in this language became like eating (and having to smell) dead, rotting fish heads.

[edit] Example Program

Note: the standard shell adds >> characters for readability.

>> i
>> 
>> o
1
>> d

This program prints the ASCII values of the characters in the string "Hello world".

iisiiiisiiiiiiiioiiiiiiiiiiiiiiiiiiiiiiiiiiiiioiiiiiiiooiiio
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddo
dddddddddddddddddddddsddoddddddddoiiioddddddoddddddddo

[edit] Implementations

Some of these implementations may not be considered fully compliant, sometimes because an implementor has implemented the intuitive meaning of the commands rather than the subtle deadfish way. For some of the implementations it may be hard for people other than the implementor to tell whether they are compliant or not.

[edit] Bash

#!/bin/bash

no=0

while true; do
	((no==256||no<0)) && no=0
	echo -n '>> ' # prompt
	if read; then
		case $REPLY in
			d) ((no--)) ;;
			i) ((no++)) ;;
			o) echo $no ;;
			s) no=$((no*no)) ;;
			*) : ;;
		esac
	else
		echo # on EOF
	fi
done

[edit] Befunge-93

v  Deadfish in Befunge
0
>0" >>">:vv            <
,#        _$:vv-*5+7*44
+     v    <  _:*v    
:  $  v^,_v^.<   >    
5> ~    >#$>:375**-v
^     < $ #v-*:*25:_$1+
^#-*65-*99:_$1-       #v
 ^  _$0~^ >:1+v
   -^>    #1-#_1+:48:**

[edit] Brainfuck

Implementation by David Catt (User:David.werecat), reads one line of input at a time (for compatibility with most brainfuck interpreters) and interprets only one instruction per line

>+[<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..-------
-----------------------.[-]>>[-]+>,----------[-----------------------------
-------------------------------------------------------------[-----[------[
----[<->[-]]<[>>>[-]>[-]>[-]>[-]<<<<[>+>+>+<<<-]>[>[<<+>>-]>[>+<-]>[<+<+>>-
]<<<-]<<<-]>]<[>>>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<[->+>>>>>+<[-]+<<<<---------
-[>>>>[<++++++++++<<->>>-]<+<<<-]>>>[<<<+>>>-]<<+>>>[-]+<<<----------[>>>[<
++++++++++<->>-]<+<<-]>>[<<+>>-]<+<<<]>>>>[-]>[-]<<[>+<<<<[-]++++++++++++++
++++++++++++++++++++++++++++++++++>>>[<<<+>>>-]<<<.>>>]>[<<<<[-]+++++++++++
+++++++++++++++++++++++++++++++++++++>>[<<+>>-]<<.>>>>-]<<[<<[-]+++++++++++
+++++++++++++++++++++++++++++++++++++>>[<<+>>-]<<.>>]<<[-]+++++++++++++++++
+++++++++++++++++++++++++++++++>[<+>-]<.[-]++++++++++.---------->>>>>>[<<<<
<<+>>>>>>-]<<<<<<<<-]>]<[>>+<<-]>]<[>>>[-]+>[-]<<[>[-]>+<<-]>>-[<<+>>-]<<>[
<+>-]<<<-]>]<[>-<-]>+[,----------]<<]

[edit] C

/* <-- Deadfish Interpreted Computer Language --> */
/* <-- Programmed by Jonathan Todd Skinner    --> */

/* <-- Include Header File --> */
/* Updated the Code to Remove Uneeded Header Includes - JTS */
#include <stdio.h>

/* <-- Declare some variables --> */
unsigned int x; /* make a positive integer and call it x */
char usrinput; /* string to hold user input */

/* <-- Declare a function --> */
void entercommand(void);

/* <-- Start Main Function --> */
int main(void)
{
	/* At beginning of x is always 0 */
	x = 0;
	entercommand();
}

/* <-- Enter Command --> */
void entercommand(void)
{
	/* Accept User Input */
	printf(">> "); /* output shell symbol */
	scanf("%c",&usrinput); /* scan for user input that is char */
	/* Check for commands and do action */
	/* Make sure x is not greater then 256 */
	if(x == 256) x = 0;
	if(x == -1) x = 0;
	if(usrinput == 'i')
	{
		x++;
		entercommand();
	}		
	else if(usrinput == 'd')
	{
		x--;
		entercommand();
	}
	else if(usrinput == 'o')
	{
		printf("%d\n",x);
		entercommand();
	}
	else if(usrinput == 's')
	{
		x=x*x;
		entercommand();
	}
	else
	{
		printf("\n");
		entercommand();
	}

}

[edit] C++ templates

#include <iostream>

//
#define PROGRAM i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,o,s,i,o,i,i,i,i,i,i,i,s,s,s,o
//

template <char n, typename Ns>
struct Cons {
  static void print() {
    Ns::print();
    std::cout << n;
  }
};

struct Nil {
  static void print() {}
};

template <typename Ms, typename Ns> struct Append;

template <typename Ns>
struct Append<Nil, Ns> {
  typedef Ns String;
};

template <char m, typename Ms, typename Ns>
struct Append<Cons<m, Ms>, Ns> {
  typedef Append<Ms, Ns> Next;
  typedef Cons<m, typename Next::String> String;
};

#define INS(name, expr) \
  struct name { \
    template <int n, typename Out> struct Result { \
      static const int value = expr; \
      typedef Out Output; \
    }; \
  }

INS(i, n + 1);
INS(d, n - 1);
INS(s, n * n);

template <int n> struct DecimalLoop;

template <> struct DecimalLoop<0> {
  typedef Nil String;
};

template <int n> struct DecimalLoop {
  typedef DecimalLoop<n / 10> Next;
  typedef Cons<'0' + (n % 10), typename Next::String> String;
};

template <int n> struct ToDecimal;

template <> struct ToDecimal<0> {
  typedef Cons<'\n', Cons<'0', Nil>> String;
};

template <int n> struct ToDecimal {
  typedef Cons<'\n', typename DecimalLoop<n>::String> String;
};

struct o {
  template <int n, typename Out> struct Result {
    static const int value = n;
    typedef typename Append<typename ToDecimal<n>::String, Out>::String Output;
  };
};

template <int n> struct Wrap {
  static const int value = n < 0 || n == 256 ? 0 : n;
};

template <typename... Is> struct Seq;

template <typename I, typename... Is>
struct Seq<I, Is...> {
  template <int n, typename Out> struct Result {
    typedef typename I::template Result<n, Out> A;
    typedef typename Seq<Is...>::template Result<Wrap<A::value>::value, typename A::Output> B;
    typedef typename B::Output Output;
  };
};

template <> struct Seq<> {
  template <int n, typename Out> struct Result {
    typedef Out Output;
  };
};

int main() {
  Seq<PROGRAM>::Result<0, Nil>::Output::print();
}

[edit] Commodore 64 BASIC

Type "H" to quit. ((Fixed to comply with the Deadfish 0-255 rule (again (again)))) You can download a "better" version of in the "External resources" section.

10 INPUT A$
20 IF A$="I" THEN B = B+1
21 IF A$="D" THEN B = B-1
22 IF A$="S" THEN B = B*B
23 IF A$="O" THEN PRINT B
24 IF A$="H" THEN END
31 IF B = 256 THEN B = 0
32 IF B = -1 THEN B = 0
33 GOTO 10

[edit] dc

# Implements XKCD variation of Deadfish.
[p]1:z[d*]2:z[1+]3:z[1-]4:z[0sB]dsAx[lB0>AlB256=A0d?lBz;zxsBclCx]dsCx

Is this strange program? Why is it XKCD variation instead of normal Deadfish? It doesn't have any "k" or the ASCII code of "k" in it? Are you good at dc?

[edit] Falcon

no=0
loop
  if no==-1 or no==256
    no=0
  end
  >> ">> "
  the_cmd = input()
  switch the_cmd
    case "d"
      no=no-1
    case "i"
      no=no+1
    case "o"
      > no
    case "s"
      no=no*no
  end
end

[edit] FALSE

[0~]["
>> "^
\$\$256=\1_=&[%0]?\
$'i=[\1+\]?
$'d=[\1-\]?
$'s=[\$*\]?
 'o=[$,]?
]#

[edit] Felix

include "std/textio";
open Text_file;
var a : int;
while {true}
{
  write(stdout, ">>> ");
  a = if a == 256 or a < 0 then 0 else a;
  match readln stdin with
  | "i\n" => { ++a; }
  | "d\n" => { --a; }
  | "s\n" => { a*=a; }
  | "o\n" => { print a; endl; }
  endmatch;
};

[edit] Forth

\ Type 'h' to halt
: MAIN
  0 BEGIN
    DUP 256 = OVER -1 = OR IF DROP 0 THEN
    KEY CASE
      'i' OF 1+ ENDOF
      'd' OF 1- ENDOF
      's' OF DUP * ENDOF
      'o' OF DUP . ENDOF
      'h' OF DROP EXIT ENDOF
    ENDCASE
  AGAIN
;
MAIN BYE

[edit] Glass

{M[moO!iI!aA!sS!n<0>=c<1>=/cc<1>ie.?as.?=ec*=/e">> "oo.?fil.?=gf
*sl.?=hg*=l<-1>n*ae.?<256>n*ae.?aa.?=/ln<0>=l<0>=\/hjf*g*h*as.?s
i.?=kj*"i"se.?=/knn*<1>aa.?=k<0>=\kj*"d"se.?=/knn*<1>as.?=k<0>=\
kj*"s"se.?=/knn*n*am.?=k<0>=\kj*"o"se.?=/kn*o(on).?<10>s(ns).?oo
.?k<0>=\hh*<1>as.?=\e<0>=\\<10>s(ns).?oo.?]}

[edit] Haskell

main = loop (0, "")
loop :: (Int, String) -> IO ()
loop (x', s) = do
    putStr $ s ++ ">> "
    c <- getChar
    let x = case x' of -1 -> 0; 256 -> 0; _ -> x'
    loop $ case c of
        'i' -> (x+1, "")
        'd' -> (x-1, "")
        'o' -> (x, show x ++ "\n")
        's' -> (x*x, "")
        _   -> (x, "\n")

[edit] HTML / Javascript

This interpreter is online here.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><TITLE>Deadfish in HTML</TITLE>
<SCRIPT type="text/javascript">
var i=0;
function deadfish()
{
  var c=document.getElementById("cmd").value;
  document.getElementById("cmd").value="";
  document.getElementById('op').innerHTML+=
    "&gt;&gt;&nbsp;&#"+c.charCodeAt(0)+";<BR/>";
  if(c=='i') i++;
  else if(c=='d') i--;
  else if(c=='s') i*=i;
  else if(c=='o') document.getElementById('op').innerHTML+=i+"<BR/>";
  else document.getElementById('op').innerHTML+="<BR/>";
  if(i==256||i==-1) i=0;
  return false;
}
</SCRIPT>
</HEAD><BODY>
<H1>Deadfish in HTML</H1>
<DIV id="op"></DIV>
<FORM onsubmit="return deadfish()">
&gt;&gt;&nbsp;<INPUT type="text" maxlength="1" size="1" id="cmd" /><BR/>
<INPUT type="submit" value="Submit" />
</FORM>
</BODY></HTML>

[edit] itflabtijtslwi

Another implementation using a unary representation. On the machine I tested it with, it did not manage to print numbers much larger than 1000 in the time I had patience to wait.

/  / //
 //
    /*/()()()()()()()()()()()()()()()()/
    /./<\\\\>\\\\\\/
    /P1/
        >> 
        GGC.0GG
        ./N.a****************N.b./N.aN.b./
        ./C.a.\.\iC.b./
            .\./N.a.\./.\.\.\./N.\0.\.\.\./.\./
            .\./N.b.\./().\.\.\./.\./
        ./
        ./C.a.\.\dC.b./
            .\./N.a.\./.\.\.\./N.\0.\.\.\./.\./
            .\./()N.b.\./.\.\.\./.\./
            .\./N.b.\./.\.\.\./.\./
        ./
        ./C.a.\.\oC.b./
            .\./N.a.\./.\.\.\./N.\1.\.\.\./.\./
            .\./N.b.\./.\.\.\./
                .\.\.\./N.\d().\.\.\./N.\d1N.\d.\.\.\./
                .\.\.\./1N.\d.\.\.\./N.\d1.\.\.\./
                .\.\.\./N.\d1.\1.\1.\1.\1.\1.\1.\1.\1.\1.\.\.\./
                    1.\.\.\.\N.\d
                .\.\.\./
                .\.\.\./N.\cN.\d.\.\.\./N.\c.\.\.\./
                .\.\.\./N.\c.\.\.\./N.\d.\.\.\./
                .\.\.\./N.\e.\.\.\./N.\d.\.\.\./
                .\.\.\./1.\1.\.\.\./2.\.\.\./.\.\.\./2.\1.\.\.\./3.\.\.\./
                .\.\.\./2.\2.\.\.\./4.\.\.\./.\.\.\./2.\3.\.\.\./5.\.\.\./
                .\.\.\./4.\2.\.\.\./6.\.\.\./.\.\.\./4.\3.\.\.\./7.\.\.\./
                .\.\.\./4.\4.\.\.\./8.\.\.\./.\.\.\./4.\5.\.\.\./9.\.\.\./
                .\.\.\./N.\dN.\d.\.\.\./0N.\d.\.\.\./
                .\.\.\./N.\d.\.\.\./.\.\.\./
                N.\cN.\dN.\1N.\e

                .\.\.\./N.\0.\.\.\./N.\1.\.\.\./
               .\./
        ./
        ./C.a.\.\sC.b./
            .\./N.a.\./.\.\.\./N.\1.\.\.\./.\./
            .\./N.b.\./.\.\.\./
                .\.\.\./N.\c().\.\.\./N.\1N.\c.\.\.\./
                .\.\.\./N.\c.\.\.\./.\.\.\./
                .\.\.\./N.\0.\.\.\./N.\cN.\1.\.\.\./
               .\./
        ./
        ./C.a./.\./W.b.\././
        ./C.b./.\./
            .\./N.a.\./.\.\.\./N.\0.\.\.\./.\./
            .\./N.b.\./.\.\.\./.\./

        ./
        C.a.\C.0C.b
        ./<.\>./<.\.\.\.\>.\.\.\.\.\.\./
        ./P.1./P.2./
        ./P.0./P.1./
        ./<.\>././
        ./P.\2./P.1./
        N.aN.0N.b
        P.0
    /
    /P0/P1/
    /<\>//
    /P2/P1/
    /N0//
    P0

[edit] Java

// Deadfish in Java -- JTS
// Compiled with JDK 6 and tested with JRE 6 on Ubuntu 9.0.4
// And yes, I do hate Java like most people and I hate how I have to do it for comp sci!
import java.util.Scanner;
public class Deadfish
{
	public static void main(String args[])
	{
		Scanner comm = new Scanner(System.in);
		boolean isSquared = false;
		int x = 0;
		String usrinput;
		while(true)
		{
			System.out.print(">> ");
			usrinput = comm.next();
			if(usrinput.contentEquals("i"))
			{
				if(x >= 256 && isSquared == false)
					x = 0;
				x++;
			}
			else if(usrinput.contentEquals("d"))
			{
				if(x <= -1 && isSquared == false)
					x = 0;
				x--;
			}
			else if(usrinput.contentEquals("o"))
				System.out.println(x);
			else if(usrinput.contentEquals("s"))
			{
				if(x >= 256)
					isSquared = true;
				x = x * x;
			}
			else
				System.out.println();
		}
	}
}
//FIN

[edit] Lua

#!/usr/bin/env lua

accumulator = 0
while true do
    io.write(">>> ")
    local input = io.stdin:read'*l'
    if accumulator == 256 or accumulator < 0 then accumulator = 0 end
    if input == "i" then
	accumulator = accumulator + 1
    elseif input == "d" then
	accumulator = accumulator - 1
    elseif input == "s" then
	accumulator = accumulator ^ 2
    elseif input == "o" then
	print(accumulator)
    end
end

[edit] METAFONT

This is limited range due to limit of numbers in METAFONT.

scrollmode;
warningcheck:=0;
inner end;
Q:=0;
def Z = if(Q<0)or(Q=256):Q:=0;fi enddef;
def i = Q:=Q+1;Z; enddef;
def d = Q:=Q-1;Z; enddef;
def s = Q:=Q*Q;Z; enddef;
def o = message decimal Q; enddef;
def h = ;end; enddef;

[edit] Pascal

program deadfish_shell;
label 10,20;
var
a:char;
b:integer;
begin
10: write(‘>>’);
readln(a);
case a of
‘I’ : b:=b+1;
‘D’ : b:=b-1;
‘S’ : b:=b*b;
‘O’ : writeln(b);
‘H’ : goto 20;
end;
goto 10;
20:
end.

[edit] Perl

#!/usr/bin/perl -w

my $acc=0;
while (1) {
    print ">> ";
    $_ = <>;
    if ($acc==-1 or $acc==256) { $acc=0; }
    if (/^i$/) { $acc++; }
    elsif (/^d$/) { $acc--; }
    elsif (/^o$/) { print $acc, "\n"; }
    elsif (/^s$/) { $acc*=$acc; }
    else { print "\n"; }
}

[edit] Pure

using system;
fish a "i" = a+1;
fish a "d" = a-1;
fish a "s" = a*a;
fish a "o" = a when puts (str a) end;
limit a = if a == 256 || a < 0 then 0 else a;
main a = (printf "%s " ">>>") $$ (main (fish (limit a) (gets)));
main 0;

[edit] Python


"""
Deadfish Programming Language Interpreter
Programmed by Jonathan Todd Skinner
This code is hereby released into the public domain
Harry eased the mess
"""

# Initialization
accumlator = 0

# Processing/Main program loop
while True:
	# Get user input
	userInput = raw_input(">> ")
	if accumlator == 256 or accumlator == -1:
		accumlator = 0
	# Process input
	if userInput == "i":
		accumlator += 1
	elif userInput == "d":
		accumlator += -1
	elif userInput == "o":
		print accumlator
	elif userInput == "s":
		accumlator *= accumlator
	else:
		print ">>"

[edit] R

n <- 0
while(TRUE) {
  if(n==-1 || n==256) n <- 0
  cmd <- scan(n=1,what='character')
  fun <- switch(cmd,
                d=function(x) x-1,
                i=function(x) x+1,
                o=function(x) { cat(x,"\n"); x },
                s=function(x) x*x)
  if(!is.null(fun)) n <- fun(n)
}

[edit] Ruby

#!/usr/bin/env ruby
#deadfish interpreter for public domain.

no=0
loop do
   if no==-1 or no==256 then
      no=0
   end
   the_cmd = gets.chomp
   case the_cmd
      when "d" then no=no-1
      when "i" then no=no+1
      when "o" then puts "#{no}"
      when "s" then no=no*no
   end
end

[edit] The language defined by the Revised Revised Revised Revised Revised Report on the Algorithmic Language Scheme

(define (execute n cmd)
  (case cmd
    ((#\i) (+ n 1))
    ((#\d) (- n 1))
    ((#\s) (* n n))
    ((#\o) (display n) (newline) n)
    (else n)))

(define (deadfish n)
  (let ((char (read-char)))
    (cond
     ((or (= n -1) (= n 256)) (deadfish 0))
     ((eof-object? char) n)
     (else (deadfish (execute n char))))))

(deadfish 0)

[edit] Staq

&{o:&iiiqi;@X}{sq}{kq}{xi}{co}{>id}

Allows the command sets of both variations.

[edit] TeX

% Deadfish interpreter in TeX

\catcode32=9\endlinechar=-1

\newcount\accumulator

\def\checkwrapping{
  \ifnum\accumulator=256\accumulator=0\fi
  \relax
  \ifnum\accumulator=-1\accumulator=0\fi
}

\def\I{
  \advance\accumulator by 1
  \checkwrapping
}

\def\D{
  \advance\accumulator by -1
  \checkwrapping
}

\def\S{
  \multiply\accumulator by \accumulator
  \checkwrapping
}

\def\O{
  \message{\the\accumulator}
}

\tracingonline=-1
\scrollmode

\def\Activate{
  \catcode105=13
  \catcode100=13
  \catcode115=13
  \catcode111=13
}

\catcode62=11

\def\Start{
  \escapechar=-1
  \loop
    \read16 to \>>
    \>>
  \iftrue\repeat
}

\Activate
\leti=\I
\letd=\D
\lets=\S
\leto=\O
\Start

[edit] TeXnicard

To use this program, save it in the file called "deadfish.cards" and then type in "@I deadfish.cards" at the "E>" prompt. And then it change to "C>" prompt and it is ready for typing in commands of deadfish.

@. Deadfish implementation in TeXnicard.
[d[c0][]dixd256-[][0*][]ix[]]s0
(patterns)sP0
@S i
1+`0x
@S d
1-`0x
@S s
d*`0x
@S o
?s[]
@P patterns
<i
: i;
<d
: d;
<s
: s;
<o
: o;
@C main

[edit] Thutu

This stores data in unary, which explains its inefficiency and the length of one of the lines.

/=>=> =x/z=x/
*
  /=>=> =x/>
  /=1/=n=>=> =xse/
  /^i=xs(a*)e/=>=> =xs$1ae/
  /^d=xsa?(a*?)e/=>=> =xs$1e/
  /^s=xs(a*)a(b*)e/s=xs$1b$2e$1$2b/
  /^s=xs(b*)e(a*)b/s=xs$1e$2a/
  /^s=xs(b*)e(a*)$/=>=> =xs$2e/
  /^o=xs(a*)e$/o=xs$1v/
  /(=x.*[sbc])v/$1w0/
  /(=x.*[sbc])av/$1cw1/
  /(=x.*[sbc])aav/$1ccw2/
  /(=x.*[sbc])aaav/$1cccw3/
  /(=x.*[sbc])aaaav/$1ccccw4/
  /(=x.*[sbc])aaaaav/$1cccccw5/
  /(=x.*[sbc])aaaaaav/$1ccccccw6/
  /(=x.*[sbc])aaaaaaav/$1cccccccw7/
  /(=x.*[sbc])aaaaaaaav/$1ccccccccw8/
  /(=x.*[sbc])aaaaaaaaav/$1cccccccccw9/
  /(=x.*[sbc])aaaaaaaaaa(a*)v/$1bbbbbbbbbb$2v/
  /(=xsc*)bbbbbbbbbb(.*)w/$1ccccccccca$2w/
  /(=x.*)ab(.*w)/$1ba$2/
  /(=x.*)ac(.*w)/$1ca$2/
  /(=x.*)bc(.*w)/$1cb$2/
  /=xs([ca]*)aw/=xs$1av/
  /=xs(c*)w/=xs$1x/
  /=xs(c*)c(a*)x/=xs$1a$2x/
  /^o=xs(a*)x(.*)$/$2=n=>=> =xs$1e/
  /^.*=x/=n=>=> =x/
.
*
  /=xsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae/se/
.

[edit] Unlambda

This implementation uses Church numerals, which are essentially unary. Use large ones at your own risk.

````sii
 ``s``s`ks ``s``s`kskk
  `k ``s``s `d`k `````.>.>. @ic
      `k ``s``s``s``s`k?i`kii`k ``s``s`ks ``s`k`s`ks ``s`k`s`kk i `ki
          ``s``s``s``s`k?d`kii`k
           ``s``s``si
            `k ``s``s`ks ``s`k`si
                ``s`kk ``s``s`ks ``s`k`s`ks ``s`k`s`kk ``si`kk `ki
                ``s`kk ``si`kk
            `k`k`ki `k`ki
          ``s``s``s``s`k?o`kii`k
           ``sk ``s`kr ``s`k
            ```sii ``s `k `s``s``si
             `k ``s``s``si`kk
                 ``s`k`s``si`k
                  `k``si`k `k``si`k `k``si`k `k``si`k `k``si`k
                   `k``si`k `k``si`k `k``si`k `k``si`k k
                  ``s`kk ``s``s`ks``s`k`s`ks ``s`k`s`kk ``si`k`ki `ki
                 ``s`k`s``s`ks``s`k`sik ``s`kk``s`kk``si`k`ki
             `ki ``s`kk
              ``s``s`ks ``s`k`s`ks ``s`k`s`kk
               `k ``s``si`k.9 `k ``s``si`k.8 `k ``s``si`k.7 `k ``s``si`k.6 `k
                   ``s``si`k.5 `k ``s``si`k.4 `k ``s``si`k.3 `k ``s``si`k.2 `k
                   ``s``si`k.1 `k `k.0
               ``s`kk
                ``s``s`ks``s``s`ks
                 `k ``s`kc ``s`k`s`k`k`ki ``s``s`ks``s``s`ksk `k`k``si`ki `kk
                 ``s``s`kskk `ki
            ``s `k`s``s`ks k i
          ``s``s``s``s`k?s`kii`k ``s``s`ks k i
          ``si`kr
      ``s``s`kc
       ``s`k`s`k`ki
        ``s``s`ks ``s``s`ks ``s``s`ks k `k``s`k`sik
         `k `k ``````s``s`ks k ``s``s`ks k i
                ``s``s`ks k i ``s``s`ks k i
                k ``si`ki
         `k ``s`kd ``si `k`k`ki
       i
 `ki

[edit] Visual Basic .NET

Implementation by David Catt (User:David.werecat) which allows a program file to be specified as a command line parameter.

Option Explicit On
Option Strict On
Module Deadfish
	Dim Val As Integer = 0
	Sub Main()
		Dim ProgCode As String = ""
		Try : ProgCode = My.Computer.FileSystem.ReadAllText(Command().Trim(""""c))
		Catch : End Try
		For Each C As Char In ProgCode
			Interpret(C)
		Next
		While True
			Console.Write(">> ") : Interpret(Console.ReadKey.KeyChar)
		End While
	End Sub
	Sub Interpret(ByVal C As Char)
		Select Case C
			Case "d"c : Val -= 1 : Console.WriteLine()
			Case "i"c : Val += 1 : Console.WriteLine()
			Case "o"c : Console.WriteLine() : Console.WriteLine(Val.ToString())
			Case "s"c : Val = Val ^ 2 : Console.WriteLine()
		End Select
		If (Val < 0) Or (Val = 256) Then Val = 0
	End Sub
End Module

[edit] Vorpal

method() {
    acc = 0
    while (1 > 0) {
        input = '>> '.input()
        if ((acc == 256) || (acc < 0)) {
            acc = 0
        }
        if (input == "i") {
            acc = acc + 1
        } else {
            if (input == "d") {
                acc = acc - 1
            } else {
                if (input == "s") {
                    acc = acc * acc
                } else {
                    if (input == "o") { 
                        acc.print()
                    }
                }
            }
        }
    }
}

[edit] WTFZOMFG

'>> "
_2 + 
( 
_0 %4 _4 ~-256 | { _0 =0 } _3
> +
> > ^
& > @i | { _0 + _3 } <
& > @d | { _0 - _3 } <
& > @s | { _0 & m _3 } < 
& > @o | { _0 \ '\n" _3 } <
& > ~-10 | { '>> " } <
+
)

[edit] ZiziQue

[Start]
!i^inc"Increment
!d^dec"Decrement
!s^sqr"Square
!o^out"Output
.
[out]
"{number}
^Start
[inc]
+number
^Start
[dec]
-number
^Start
[sqr]
=number,{{number}*{number}}
^Start

[edit] See also

[edit] External resources

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox