Kite is a programming language for the Retroputer that is designed to be easy to learn and use, while also being useful and stepping stone to other programming languages. It's also intended to be easy to parse and quick to execute.
Design principles:
fn
repeat
, etc.const
and mutability via let
string(...)
and number(...)
)print
, prompt
, etc.(Scratch)
0 // Random Number Game
10 fn main
20 print("Random Number Game")
30 print("")
40 print("I've chosen a number between 0 and 100. You have to try to guess it.")
50 repeat
60 playGame()
70 let response = prompt("Try again?")
80 until lowercase(response) not in ["y", "yes"]
90 print("Ok, bye! Have fun until next time!")
99 end fn main
200 fn playGame
210 const num = floor(random() * 100)
220 let tries = 0
230 let guess = 0
240 repeat
250 print("Try #" + string(tries))
260 guess = number(prompt("Your guess?"))
270 when
280 guess < num then print("Nope! Too low.")
290 guess > num then print("Wrong! Too high.")
300 else print("Wow! You got it!")
310 end when
320 tries = tries + 1
330 if tries > 20 then print("Oops! You ran out of turns.")
330 until guess == num or tries > 20
340 end fn playGame
fn double
take x
give x * 2
end fn double
double(2) => 4
map([1, 2, 3], double) => [2, 4, 6]
map([1, 2, 3], fn << x >> x * 3) => [3, 6, 9]
fn lowerCharCode
take charCode
if charCode in [65 .. 91] then charCode = charCode + 32
give charCode
end fn lowerCharCode
fn lower
take str
give split(str) |
map(_, ord) |
map(_, lowerCharCode) |
map(_, stringFromCode) |
unsplit(_)
end fn lower
lower("HeLlO") => "hello"