main.spud
saved β Β· Ln 1, Col 1
terminal
idle
every program ends with run spud
SpudLang reads top-to-bottom. Nothing executes until it hits run spud β that's the ignition. It must be the very last line of the file.
mash "Hello, potato!" run spud
Plant with spud. Reassign with just the name β but only if it already exists.
spud age = 25 age = 26 # ok, age exists score = 10 # ERROR: never planted
Blocks { } have their own scope. Variables don't leak out.
mash prints. ask "prompt" waits for the user to type β always returns text, even if they typed a number.
spud name = ask "What's your name? " mash "Hello, " + name spud n = num(ask "Age? ") # convert to number
ish age >= 18 { mash "Can vote." } nope ish age >= 13 { mash "Teenager." } nope { mash "Kid." }
loop i from 1 to 5 { } β counts 1..5, inclusive. i only lives inside.keep cond { } β repeats while true. Change something inside or it overheats.peel β break out of the loop.sprout β skip to the next round.loop i from 1 to 10 { ish i % 2 == 0 { sprout } mash i }
recipe add(a, b) { serve a + b } mash add(2, 3) # 5
Recipes without serve return nada.
42, 3.14, -7"hello" or 'hi'yep (true), nah (false)nadaand, or, not==, !=, <, >, <=, >=Only nah, nada, 0, and "" are false. Everything else is true.
run spud.spud before use.{ } have their own scope.+ works on two numbers OR two texts. Mixing is an error β use str() or num().peel / sprout only inside loops.1 == "1" is false.len(text) β length of a stringscream(text) / whisper(text) β uppercase / lowercaseabs, floor, ceil, round, sqrt β mathrandom(lo, hi) β random integer, inclusivestr(x) / num(x) β convert text β numbertype(x) β description of xmax(...) / min(...) β largest / smallestrepeat(text, n) β repeat textpotato() β π₯