A Simple human readable functional programming language
- Simple
- Readable
- Ease of learning
(basic) python clone with brackets
name = "peter parker"
age = 21
variables are immutable by default
for mutable variables, use the let keyword
let is_gwen_alive = true
a = number(input(""))
if a % 5 is 0 and a % 7 is 0 {
print("FizzBuzz")
} else if a % 5 is 0 {
print("Fizz")
} else if a % 7 is 0 {
print("Buzz")
} else {
print(a)
}
input(args...) write the args in the console and read an input from it
number(arg) convert the string to number if possible
note: is and is not are identity operators similar to == and != respectively
note: curly brackets are optional for a block if it contains only single statement
loop {
print("got stuck in an infinite loop")
}
exits when the condition gets false
let a = 10
loop while a > 0 {
print(a)
a -= 1
}
exits when the condition gets true
let a = 10
loop until a is 0 {
print(a)
a -= 1
}
note: loops are just single statement
you can substitute loop block with any other
regular blocks
if a is 0 loop {
print("a is zero, is zero a number?")
}
if a < 0 loop while a is 0 {
print($"a is negative and it is {a}")
a += 1
}
else if a is 0 loop while a < 10 {
print($"a is single digit and it is {a}")
a += 1
}
else loop while a < 100 {
print($"a is double digit and it is {a}")
a += 1
}
note: you can use $ to interpolate variables in strings
add = (a, b) => a + b
connectToDB = (url) => {
if url is "" {
return false
}
# connect to the database
connection
}
note: by default functions return the last expression
print(takes any number of arguments and prints them to stdout)input(takes optional string as argument and prints it to stdout and returns the input from stdin)number(converts string to number)- yet to add more