Skip to content

Instantly share code, notes, and snippets.

@ceylonwebide
ceylonwebide / README.md
Last active August 13, 2017 15:08
Ceylon Web Runner: Oscilloscope

Ceylon Oscilloscope Example

Demonstrates the use of the HTML Canvas, along with some minor cuteness involving destructuring.

To run the program, just press 'Run' above. Then check out the code in the other tabs.

Adapted from [this original code][original].

@ceylonwebide
ceylonwebide / README.md
Last active August 13, 2017 15:09
Ceylon Web Runner: Solar System

Ceylon Solar System Example

This little example application demonstrates the use of Ceylon as an alternative to client-side JavaScript. In particular, the example shows:

  • a simple, typesafe, object-oriented program,
  • dependence on an external [cross-platform math module][xmath] written in Ceylon and hosted on
@ceylonwebide
ceylonwebide / strings.ceylon
Created September 26, 2015 20:52
Ceylon Web Runner: strings.ceylon
//$webrun_wrapped
shared void run() {
//Strings come in two forms, ordinary, single-quoted strings,
//where backslashes represent escapes:
print("Hello\nworld");
//And "verbatim" strings, where quotes and backslashes are
//interpreted literally:
@ceylonwebide
ceylonwebide / index.json
Last active April 19, 2016 15:16
INDEX: Alternative index for the Web IDE's Examples
{
"sets": [
{
"title": "Try out a sample:",
"items": [
{
"title": "Hello World",
"gist": "1b5a174b7fda6eb0e3a6"
},
{
@ceylonwebide
ceylonwebide / README.md
Last active October 9, 2015 23:04
INTRODUCTION

Welcome to the Ceylon Web IDE

On this page you can easily try out simple (and not so simple) code examples written in Ceylon.

To start off you can click on any of the examples listed in the side bar on the right followed by pressing the Run button in the toolbar displayed right above this text.

@ceylonwebide
ceylonwebide / main.ceylon
Last active August 13, 2017 15:10
EXAMPLE: Module Import
import ceylon.collection { LinkedList }
void run() {
value list = LinkedList{"Test 1", "Test 2"};
list.add("Test 3");
print(list);
}
@ceylonwebide
ceylonwebide / importtest1.ceylon
Created September 26, 2015 18:33
EXAMPLE: Local Import
import ceylon.language.meta.declaration {
ValueDeclaration
}
shared void run() {
for (dec in `class String`.memberDeclarations<ValueDeclaration>()) {
print(dec);
}
}
@ceylonwebide
ceylonwebide / game_of_life.ceylon
Last active November 5, 2015 09:29
EXAMPLE: Game of Life
//$webrun_wrapped
shared void run() {
// Game of Life 2.5
value seed = system.milliseconds;
value density = 0.8;
value gwidth = 180; // Number of cells horizontally and vertically
value gheight = 80; // Number of cells horizontally and vertically
@ceylonwebide
ceylonwebide / metamodel.ceylon
Last active October 28, 2015 20:59
EXAMPLE: Type-safe Metamodel
//$webrun_wrapped
shared void run() {
"You can get the metamodel of a class like this"
value stringType = `String`;
print("class ``stringType``");
for (st in stringType.satisfiedTypes) {
print(" satisfies ``st``");
}
@ceylonwebide
ceylonwebide / operators.ceylon
Created September 26, 2015 18:31
EXAMPLE: Operator polymorphism
//$webrun_wrapped
shared void run() {
// Operators are associated to specific interfaces. A type that
// satisfies such an interface can be used with the respective
// operators.
class Product(String name, Float price)
satisfies Comparable<Product> {
shared actual String string = name;
shared actual Comparison compare(Product other)
=> price <=> other.price;