Hide

Factor playground

The essential features of Factor for learning. If you are new to Factor, take a look at my tutorial.
Sources and wiki are available at http://bitbucket.org/egaga/js-factor/
Share your ideas and experiences in reddit. Direct feedback: henrik.huttunen@gmail.com

Native Words

What's this?
Native words are predefined functions with which you can start modifying the stack.

Hover on a word and you will see a description of it. Moreover, you are shown the word's stack effect, which tells how the word affects the stack. Here's an example:

( x y -- y x )

Before "--" is elements that are taken from the stack (when word is used) and after "--" are the elements that are put back. Note that the names in stack effect are only descriptive.

Factor requires you to write stack effects for your own words but this enviroment does not for ease-of-use.

Also, by hovering on word, you get an example of the use in the bottom right corner. Click on the "Step trough..." button to see the example step-by-step.

Stack

What's this?
Stack is the placeholder for values you operate on. Words (i.e. functions) modify the stack, starting from the topmost. You can add a number to stack by just writing it into the input and press enter.

History

Custom words

What's this? Save
You can define your own words (functions).

The syntax is:

: wordname <sequence of valid symbols> ;

An example : double 2 * ; which would define a word named "double" that puts number 2 on the stack and then uses multiplication word named *.

Click on "Custom words" headline and you will get all of the custom words as a string in the input. By executing that string on another session, you define all of the custom words in one go.

Alternatively, you can save them locally, if your browser supports it. Try it out!

1 2 +

Drawing canvas

What's this?
HTML5 2D Canvas. You can draw on it colored lines and rectangles. See 'graph' category on native words.

(0, 0)

(600, 400)