croczilla.com 
 home   stratified   bits&pieces   blog   
  home > oni > Samples

Oni Code Samples

Oni Core

Samples using the Oni/JS core language only.
hello-world.html
Classic Hello World program.
periodic.html
Endless loop, printing out dots in ~1s intervals.
[ concurrent-loops.html
Two concurrent ('Par'-composed) loops, periodically printing out letters 'A' and 'B'. Loop 'A' has a period of ~1s, loop 'B' has a period of ~1.4s.
concurrent-loops2.html
Two concurrent ('Par'-composed) loops, printing out letters 'A' and 'B' at random intervals of 0-2s.
recursion1.html
An endless loop which prints out a sequence of increasing integers.
Demonstrates how to set up recursive functions in Oni. (The syntax is a bit unwieldy at the moment, requiring the function in question to be wrapped in a 'Let'.)
Oni is tail-call safe, so iterative processes expressed by recursive function calls will run in constant space.
example-04.html
Google search form with delayed automatic triggering.
This Oni program is dissected in the Introduction.
testsuite/core.html
Oni core language test suite.

Oni Core + Ajax lib

Samples using the Oni/JS Ajax library in addition to the core Oni/JS language.
google_feeds.html
Demonstrates how to retrieve RSS feed items (latest slashdot post in this case) using the Google Feeds API bindings.
google_translated_feeds.html
Demonstrates use of Google Feeds & Language APIs: Retrieves latest slashdot post and translates into Spanish and Japanese.