"simple code"
1 + 2.
"simple collection stuff"
#{1. 2. 3. 4. 5.} collect: [:i | i * 2].
"making the world a bit brighter..."
world := ((lively at: 'morphic') at: 'World') current.
world setFill: (Color r: 255 g: 0 b: 0).
"Ascii art with a block"
f := [:x :y | (x + '=' times: y) + x ].
f value: '-' value: 25.
"How warm is it in Palo Alto? (Featuring a block as well, for showing off...)"
extractTemp := [:json | | getter temp |
getter := Global path: 'query.results.channel.item.condition.temp'.
temp := getter get: json.
world inform: ('In ' + loc + ' are ' + temp + ' Fahrenheit').].
loc := 'Palo Alto, CA'.
url := Strings for: 'https://query.yahooapis.com/v1/public/yql?q=%s&format=%s&env=%s'
m: 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="' + loc + '")'
a: 'json'
t: 'store://datatables.org/alltableswithkeys'.
(WebResource create: (Global encodeURI: url)) beAsync get withJSONWhenDone: extractTemp.
"make the morphs go round!"
world getSubmorphs forEach: [:morph |
morph
at: 'velocity' put: (Global p: 20 t: 20) random;
at: 'angularVelocity' put: 0.1 * Math random;
start: 100 Stepping: 'stepAndBounce'].