TurtleGrad 🐢∇

This is a tiny toy programming system inspired by several ideas:

It's parsed by nearley and the automatic differentiation is in forward-mode by dual numbers. Try some of these examples:

set i to 18!
set theta to 30!
while i do {
  forward 20!
  set theta to theta * (90 / 100!)
  turn degs[theta]
  set i to i - 1
}
set theta to degs[0.5 * 180!]
set a to 50!
set b to 100!

turn degs[-90!]
turn theta
forward a
turn neg[theta]
set phi to asin[(a / b) * sin[theta]]
turn neg[phi]
forward b
turn phi

turn degs[90!]
forward neg[15!]
turn degs[neg[90!]]
set i to 4
while i do {
  set i to i - 1
  forward 30!
  turn degs[90!]
}
set i to 20!

set theta to degs[4.5 * 10!]
set v to 1.5 * 10!

set g to -1!
set vx to v * cos[theta]
set vy to v * sin[theta]
forward -100!
while i do {
  set i to i - 1
  forward vx
  turn degs[-90!]
  forward vy
  turn degs[90!]
  set vy to vy + g
}