Welcome to Medley! Medley is...
Medley is created by @Henno Kublin, @Amanda Marques, @Nick Morgan, @Megan Richardson, @Josh Seaman, and @Tigerlilly Zietz.
- Statically Typed
Keywords in Javascript | Medley |
---|---|
function | blend |
return | squeeze |
if() | ifmelon() |
else if() | elifmelon() |
else | elsemelon |
for() | formelon() |
while() | whilemelon() |
JavaScript | Medley |
---|---|
console.log(“Hello World!”); |
juice "Hello World!" | |
Types in JavaScript | Types in Medley | Variable Declarations Example |
---|---|---|
string | stringberry |
stringberry title is "medley" | |
boolean | boolberry |
boolberry bestLanguagee is true | |
int | intberry |
intberry teamSize is 6 | |
float | floatberry |
floatberry ourIQ is 156.7 | |
Booomglean Types In Javascript | Boolean Types In Medley |
---|---|
true |
organic |
false |
gmo |
Types in Javascript | Types in Medley | Variable Declaration Example in Medley |
---|---|---|
Array | berrybasket |
berrybasket~stringberry~ s = ~"strawberry" ; "blueberry"~ | |
Dictionary | fruitbasket |
fruitbasket~stringberry, stringberry~ s = ~"key1","value1" ; "key2","value2"~ | |
Operation | Type Compatability |
---|---|
add plus |
Strings, Numbers |
subtract minus |
Numbers |
multiply times |
Numbers |
divide divby |
Numbers |
modulus mod |
Numbers |
less than less |
Numbers |
greater than more |
Numbers |
less than or equal to less equals |
Numbers |
greater than or equal to more equals |
Numbers |
strictly equal equals |
Strings, Numbers, Booleans |
logical AND apple |
Booleans |
logical OR orange |
Booleans |
Operation | Type Compatability |
---|---|
negative - |
Numbers |
negation nut |
Booleans |
increment ++ |
Numbers |
decrement -- |
Numbers |
- Single Line:
::
- Block:
::: :::
ifmelon 1 plus 1 equals 2 ->
juice "this is factual information" |
<-
formelon intberry i is 10 | i more equals num | i-- ->
juice "the number is " plus i |
<-
intberry i is 2 |
whilemelon i less 10 ->
juice " " plus i |
i++ |
<-
Javascript:
console.log('Hello World');
Medley:
juice "Hello, World!" |
Javascript:
function fibonacci(num) {
var num1 = 0;
var num2 = 1;
var sum;
var i = 0;
for (i = 0; i < num; i++) {
sum = num1 + num2;
num1 = num2;
num2 = sum;
}
return num2;
}
Medley:
blend fibonacci(intberry num) ->
intberry num1 is 0 |
intberry num2 is 1 |
intberry sum |
intberry i is 0 |
formelon i is 0 | i less num | i++ ->
sum is num1 plus num2 |
num1 is num2 |
num2 is sum |
<-
squeeze num2 |
<-
Javascript:
def odd_or_even(num):
if(num % 2 == 0) {
console.log("The number is even.");
} else {
console.log("The number is odd.");
}
Medley:
blend oddOrEven(intberry num) ->
ifmelon num mod 2 equals 0 ->
juice "The number is even." |
<- elsemelon ->
juice "The number is odd." |
<-
<-
Javascript:
function toCelsius(fahrenheit) {
return (5/9) * (fahrenheit-32);
}
Medley:
blend toCelsius(floatberry fahrenheit) ->
squeeze (5 divby 9) times (fahrenheit minus 32) |
<-
Javascript:
function firstFactorial(x) {
if (x == 0 || x == 1) {
return 1;
}
return x * firstFactorial(x - 1);
}
Medley:
blend firstFactorial(num) ->
ifmelon num equals 0 or num equals 1 ->
squeeze 1 |
<-
squeeze num times firstFactorial(num minus 1) |
<-
- Incompatible types
- Variable has already been declared
- Use of a non-initialized variable
- Invalid variable type
- Invalid types used with add, sub, mult, div, or mod
- Incorrect use of unary operator
- Index out of range
- Type mismatch in declaration
- Function missing return statement
- Mismatched function return type
- Incorrect number of function parameters
- Function call does not exist
- Break outside of loops or task
- Unreachable statement
- Types are not compatible