My favorites | Sign in
Project Logo
                
Search
for
Updated Apr 02, 2007 by cdiggins
Labels: Documentation
Tutorial  
A tutorial on the Cat language

Introduction

Cat is a functional stack-based programming language. All operations in Cat manipulate a single shared stack.

If you type a number in Cat it is pushed onto the stack as so:

>> 2
stack: 2
>> 3
stack: 2 3
>> 4
stack: 2 3 4

If you write an operator it will apply to the top two items

>> add
stack: 2 7

If you want to remove an item from the stack you can call pop:

>> pop 
stack: 2

You can also enter multiple numbers or instructions on the same line:

>> 4 4 add
stack: 2 8 

You can remove all items from a stack by calling clr:

>> clr
stack: _empty_

The three basics instructions for manipulating the stack are:

  • pop - remove top item from stack
  • dup - duplicate top item on stack
  • swap - swap the top two items on the stack

More Resources


Sign in to add a comment
Hosted by Google Code