GithubHelp home page GithubHelp logo

nomad's Introduction

#Nomad

A simple interpreter build in Go

Nomad is an interpreted programming language

It compiles the program to bytecode which is later interpreted by a stack-based virtual machine

Examples are in the examples folder

example

Fib sequence

auto fib :: func(int n) int {
    if n = 0 {
        return 0
    } elif n = 1 {
        return 1
    } else {
        return fib(n-2) + fib(n-1)
    }
}
print fib(16) // 967

2nd degree equation solver

type Equation :: {
    float a :: 0.0
    float b :: 0.0
    float c :: 0.0
}

auto solve_2nd :: func(Equation eq) [float] {
    auto delta ::  pow(eq.b, 2) - (4.0 * eq.a * eq.c)
    if delta < 0.0 {
        return [float]{};
    }
    if delta > 0.0 {
        return [float]{
            (-eq.b - sqrt(delta))/(2.0 * eq.a), 
            (-eq.b + sqrt(delta))/(2.0 * eq.a)
        }
    }
    return [float]{ (-eq.b)/(2.0 * eq.a)}
} 

auto eq :: new Equation{
    a :: 4.0, b :: 0.0, c :: -16.0,
}
print solve_2nd(eq)

Test it

go run main.go examples/fib.nd

Todo

  • Variables
  • Math
  • Literal types
  • Control flow
  • Array
  • Object
  • Advanced types
  • type checking
  • function
  • interface with go

nomad's People

Contributors

nghokeng-ycode avatar dani-gouken avatar

Watchers

 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.