/* Thyme is the homebrew scrpting language in Algodoo/Phun. There are four atom types in thyme: Int, Float, Bool and String. These types can then be used to construct aggregate types, such as Lists, and Functions. Identifiers are declared using operator:= and changed using operator=. An identifier is typeless. foo := 3; // Declares a new identifier "foo" with an initial integer vale foo = [foo, "hello", true]; // Assigns a list to the previously declared variable 'foo'. The list is heterogenous. print foo(1); // prints "hello" print foo([0,2]); // prints [3, true] isEven := (n)=>{ n%2==0 }; // Declares a function "isEven" that takes one argument and returns true if it's even */ /* for - A simple looping structure in Thyme. Used like this: for(n, (i)->{ ... }); where n is the number of times to call the function. i will be given the values 0, 1, ..., n-2, n-1 Example: for(4, (n)=>{print ((n+1) + " bottles of beer on the wall.")}) Output: 1 bottles of beer on the wall. 2 bottles of beer on the wall. 3 bottles of beer on the wall. 4 bottles of beer on the wall. */ for = (n, what)=>{ n <= 0 ? false : { for(n - 1, what); what(n-1) } }; inclusive_range = (min, max)=>{min > max ? [] : {[min] ++ inclusive_range(min + 1, max)}}; infix 2 left: _ .. _ => inclusive_range; // Usage: 1..5 == [1,2,3,4,5]