Features
What Cobalt has built in, each with a short example and what it prints.
Live values
Use <- and the value keeps itself up to date whenever what it depends on changes.
price := 20total <- price + 2price := 50out totalPrints
52
Time travel
Every value remembers its history, so you can step back.
score := 10score := 40rewind scoreout scorePrints
10
Pipes
Pass a value from one step to the next, reading top to bottom.
[50, 20, 90] >> sort >> map fx x => x * 10 >> outPrints
[200, 500, 900]
Match
Compare a value against ranges, lists and patterns.
fx grade points => give points ? 90.. => "A" | 80..89 => "B" | _ => "keep going"out grade 85Prints
B
Watchers
Run code the moment something becomes true.
score := 0on score >= 3 => out "three points!"loop 5 => score += 1Prints
three points!
Windows are built in
Add a window block and the program becomes an app. It redraws itself when a value changes.
- Layout
- row, column, grid, card, sidebar, nav, dialog, tabs
- Content
- title, text, markdown, image, table, charts, badges, progress
- Controls
- button, input, checkbox, switch, slider, select, file picker
- Games
- canvas shapes and sprites, keyboard input, game loops
- Style
- colours, shadows, hover states, fonts and animations
- Data
- save and load keep information between runs