Giter Site home page Giter Site logo

medley's Introduction

Introduction

Welcome to Medley! Medley is...

Medley is created by @Henno Kublin, @Amanda Marques, @Nick Morgan, @Megan Richardson, @Josh Seaman, and @Tigerlilly Zietz.

Features

  • Statically Typed

Types & Variable Declarations

Keywords in Javascript Medley
function blend
return squeeze
if() ifmelon()
else if() elifmelon()
else elsemelon
for() formelon()
while() whilemelon()

Built In Functions

JavaScript Medley
console.log(“Hello World!”); juice "Hello World!" |

Primitive Types

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

Data Types

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"~ |

Binary Operators

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

Unary Operators

Operation Type Compatability
negative - Numbers
negation nut Booleans
increment ++ Numbers
decrement -- Numbers

Comments

  • Single Line: ::
  • Block: ::: :::

Medley Examples

If Statements

ifmelon 1 plus 1 equals 2  ->
  juice "this is factual information" |
<-

For Loops

formelon intberry i is 10 | i more equals num | i-- ->
  juice "the number is " plus i |
<-

While Loops

intberry i is 2 | 
whilemelon i less 10 ->
  juice " " plus i |
  i++ |
<-

Hello World

Javascript:

console.log('Hello World');

Medley:

juice "Hello, World!" |

Fibonacci

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 |
<-

Function to find if a number is odd

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." |
    <-
<-

Fahrenheit to celsius

Javascript:

function toCelsius(fahrenheit) {
    return (5/9) * (fahrenheit-32);
}

Medley:

blend toCelsius(floatberry fahrenheit) ->
    squeeze (5 divby 9) times (fahrenheit minus 32) |
<-

First factorial

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) |
<-

Types of Static Semantic Errors

  • 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

medley's People

Contributors

meganmrichardson avatar jseaman1 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.