Code Samples

A small sampling of 8th code

It’s all about the code

In order for you to get a feel for 8th™ we’ve put together a short page with a few samples. First we would like to point you to the Hello, world sample.

8th uses JSON for data declaration, so for example an array of strings could be declared like this:

] var, animals

You can easily iterate over the array you just created:

animals @ 
( . " is item number " . . cr )

That will print out cat is item number 0 (etc.) for each item in the array. Working with a “map” (same as a “dictionary” or “hashtable” in other languages) is just as easy:

  "cat" : "feline",
  "dog" : "canine",
  "rat" : "murine"
} var, animals

animals @ 
( swap . " is " . . cr )

That will print out rat is murine and so forth. You may notice that “each” is prefaced by “a:” for arrays and “m:” for maps. This is because there are (at least) two different “each” words, which reside in different namespaces and operate on different kinds of items.

Rather than give an entire lesson here, we’ll point you to these resources: