--- LANGUAGE SERVER IS TEMPORARILY DISABLED, PLEASE COME BACK LATER TO RUN THE DEMOS ---
The Quantleaf Language is a natural language like programming language. The purpose of this language is to make programming something that more people could enjoy.
You do not need to install anything to start writing code. Just visit quantleaf.com and get started.
For a quick "deep dive" check this linear regression example, or see other examples here.
Two things to note. The project is currently in the testing phase which means major changes could occur. The documentation below is in English but the Quantleaf Language can also be written in Swedish, but is not yet well documented. The language will also in the future support/understand more languages (and is by design intended of doing so).
You can get help with issues here.
print(1+1)
or
print 1+1
or end your program with some value
sqrt(2)
Variable names are case insensitive. Variable names can contain spaces.
A number
some variable = 123
A string (text) variable.
some variable = "hello world"
A string (text) variable. Quations can be omitted for string variables if the string is "meaningless"
some variable = hello world
a list = A,B,C
or
a list = [1,2,3]
Example of two dimensional (a table)
a complex kind of list = [[A,"B",123],[456,???,hello world]]
You can also use the word "contains" to build a list
a list of todos contains do laundry, cleaning and call grandma
a list = []
a list with an element = a list add "hello world"
a list = [hello world]
a list without an element = a list remove "hello world"
Flip a matrix along its diagonal
a list = [1,2,3]'
or
a list = transpose([1,2,3])
Indexing starts at 0 (first element starts at position 0)
Select row by indices
the best fruits = [banana, orange]
print the best fruits [0]
Select row by ranges
some matrix = [[1,2,3],[4,5,6]]
a smaller matrix = some matrix[0,1:3]
print(a smaller matrix)
or
some matrix = [[1,2,3],[4,5,6]]
a smaller matrix = some matrix row 0 and column from 1 to 3
print(a smaller matrix)
You can select columns and rows by value. If you select a column with name "Apple", you expect the first row to contain the element "Apple" somewhere. The selected column will not include the first row. Same concept holds for rows.
fruit price matrix = [[Apple, Orange],[2,3]]
apple price = fruit price matrix column Apple
print(apple price)
for i = 1 to 10 print (i)
or
foreach fruit in [banana, apple, kiwi] print fruit
x = 123
if x > 1
print hello
else if x = 2
print world
else
print "something"
You can write function in many different ways. Functions can return values, by writing return before something, or by writing the value last. A few examples of equivalent functions:
f(x) = x^2
f(x)
x^2
f(x) { x^2 }
f(x) =
{
x^2
}
f(x)
return x^2
f(x)
square = x^2
square
Below are some small examples of the equivalent programs using if statements and return statements:
taste(fruit) if fruit = apple good else bad
taste(fruit)
if fruit equals apple
return good
return bad
taste(fruit)
{
if(fruit == apple)
return good
bad
}
You can pass arguments by position or assign by name (or both).
By position
f(x,y)=x*y
print(f(1,2))
By name
f(x,y)=x*y
print(f(y=2,x=1))
some data object = get <URL THAT RETRIEVES JSON>
some property = property of some data object
same property = some data object.property
f(x) = x^2
print(minimize f)
f(x) = x^2 s.t. x > 0
print(minimize f)
print(minimize f(x) = x^2 s.t. x > 0)
some data = get <YOUR URL>
some data = get <YOUR CSV URL>
print(some data[2,3])
"Comments are written with surrounding quotation symbols"
print 1 + 1
x = [1,2,3]
y = [3,4,5]
plot(x,y, label = Some line)
x = [1,2,3,3,3,3,4,5,5,5,5,5]
histogram(x, bars = 4, label = Some histogram)
x = [apple, apple, orange, pineapple]
bar chart(x,label = Fruits)
x = [1,2,3]
y = [3,4,5]
scatter plot(x,y, label = Data)
Use the word "and" or ","
x = [1,2,3,4]
y = [3,2,7,0.5]
z = [1,2,3,3,3,3,3,4]
plot(x,y, label = Some line) and histogram(z)
This method will try to convert content into a table and visualize it
table(get(<YOUR CSV URL>))