52 lines
1.4 KiB
Plaintext
52 lines
1.4 KiB
Plaintext
---
|
|
sidebar_position: 2
|
|
---
|
|
|
|
import { SquiggleEditor } from '../src/components/SquiggleEditor'
|
|
|
|
# Squiggle Language
|
|
|
|
The squiggle language has a very simply syntax. The best way to get to understand
|
|
it is by simply looking at examples.
|
|
|
|
|
|
## Basic Language
|
|
|
|
As an example:
|
|
|
|
<SquiggleEditor initialSquiggleString={`value_of_work = 10 to 70
|
|
value_of_work`} />
|
|
|
|
Squiggle can declare variables (`value_of_work = 10 to 70`) and declare exports
|
|
(the lone `value_of_work` line). Variables can be used later in a squiggle program
|
|
and even in other notebooks!
|
|
|
|
An export is rendered to the output view so you can see your result.
|
|
|
|
the exports can be expressions, such as:
|
|
|
|
<SquiggleEditor initialSquiggleString="normal(0,1)" />
|
|
|
|
## Functions
|
|
|
|
Squiggle supports functions, including the rendering of functions:
|
|
|
|
<SquiggleEditor initialSquiggleString={`ozzie_estimate(t) = lognormal({mean: 3 + (t+.1)^2.5, stdev: 8})
|
|
ozzie_estimate
|
|
`} />
|
|
|
|
## Squiggle units
|
|
|
|
Squiggle supports using suffixes at the end of numbers to refer to units:
|
|
|
|
<SquiggleEditor initialSquiggleString={`
|
|
us_economy_2018 = (10.5 to 10.9)T
|
|
growth_rate = 1.08 to 1.2
|
|
us_economy(t) = us_economy_2018 * (growth_rate^t)
|
|
us_population_2019 = 320M to 330M
|
|
us_population_growth_rate = 1.01 to 1.1
|
|
us_population(t) = us_population_2019 * (us_population_growth_rate^t)
|
|
gdp_per_person(t) = us_economy(t)/us_population(t)
|
|
gdp_per_person`} />
|
|
|