Skip to content

Instantly share code, notes, and snippets.

@aviaryan
Created April 13, 2017 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aviaryan/5f829a9ab14cdcf96ae23f17ae3c4ec6 to your computer and use it in GitHub Desktop.
Save aviaryan/5f829a9ab14cdcf96ae23f17ae3c4ec6 to your computer and use it in GitHub Desktop.

LaTTe Demo

Hello World

:help
:reset
a = 2
a + 4
result = a + 4
result + 2
s1 = "Hello"
s2 = "World
res = s1 + " " + s2

Java Inbuilt Classes

a = BigInteger("3181293819812933132")
a + BigInteger("19239912399499124992")
a + 23912939219942192439494393949243

list = ArrayList()
list add 'first str'
list + 'second str'
list
list clear
list
newList = [1, 2, 3]

Control

s=2
if s==2
    print("s is 2")
else
    print("s is not 2")

Arithmetic

x = 3 ^ 2
z = 3/2  # 1
z = 3/2.0  # 1.4
num = 4
num << 1  # 8

Fun functions/classes

Classes created with same name as function. Constructor has the fun function.

fun isMoreThan2(o)
    return o>2
isMoreThan2(1)
isMoreThan2(2)
isMoreThan2(3)

Classes

class User(id,name)
    getId()=id
    getName()=name
    toString():String="User("+id+", "+name+")"
    equals(o):bool
        if o is type User
            return id==o.id and name==o.name
        return false

user = User(1, "avi")
user.getId()
user
user is type User
s = 2
s is type User    

Data Classes

data class User(id:int, name)
user = User(id=1, name="shanks")
user.name

Lambda

var square = (a) -> a*a
square(5)
var add = (a,b) -> a+b
add(5,6)

Please visit http://latte-lang.org/ for more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment