Skip to content

Instantly share code, notes, and snippets.

@matyklug18
Last active December 28, 2019 23:27
Show Gist options
  • Save matyklug18/8fa51218608503f182120a99cb408f75 to your computer and use it in GitHub Desktop.
Save matyklug18/8fa51218608503f182120a99cb408f75 to your computer and use it in GitHub Desktop.
//hello world, Java style:
import System;
public class Main {
public static void main(str[] args) {
System.stdout.println("hello world");
}
}
//hello world, Python style:
println("hello world")
//mix and matching of these:
println("hello ");
public class Main {
int main(str[] args) {
println("world!");
}
}
//OOP
public class Person {
public eat() {
//eat
}
public void sleep() {
//sleep
}
}
public class Programmer : Person {
public void programm() {
//make stuff
}
}
public class JavaProgrammer : Programmer {
useIDE() {
//make stuff
}
@Override
programm {
useIDE();
}
}
//const must return for the same inputs, the same outputs.
const int addthenumbers(int a, b) {
return a+b;
}
//allows for more return types
auto<int, str, float> getFromString(str string) {
if(Numbers.isInt(string)) {
return Numbers.strToInt(string);
} else if(Numbers.isFloat(string)) {
return Numbers.strToFloat(string);
} else {
return string;
}
}
//copies
public void doNotChange(#int notGonnaBeChanged) {
notGonnaBeChanged = 0;
}
void main {
int value = 1;
doNotChange(value);
println(value); //prints 1;
}
//var types
var x = 0;
x = "hello";
//biiig number
bign n = 18446744073709551615 //easy
n = 340282366920938463463374607431768211455 //yep, 128 bits/16 bytes
//512 bits, 64 bytes...
long bign x = 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084095
//function args
int addThreeNumbers(int a, int b, int c) {
return a+b+c;
}
int five() {
static int i = 0;
println(i);
i++;
return 5;
}
for(0..10)
println(addThreeNumbers(five, 1, 2)); // prints 0\n7, then 1\n7, then 2\n7, etc...
//var name vars
for(i=0..2)
up int i${i} = i;
println(i0, i1, i2); //prints 0\n, 1\n, 2\n
//string replaces
println("$0 $3 $1 = $2".refactor(0..2::func(i) { //very simple calculator
i0 = getin();
i1 = getin();
i3 = getin();
i2 = i0 operate(i3) i1;
}.(INDEX, VAR)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment