Skip to content

The classic monkey interpreter, following the guide given in the writing an interpreter in go book

License

Notifications You must be signed in to change notification settings

waridh/go-monkey-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-monkey-interpreter

Overview

This project is the interpreter for the Monkey Programming language, the spec of which is written by Thorsten Ball, following the wonderfully written Writing An Interpreter In Go.

Monkey is an expression based programming language with support for basic data types, such as booleans, integers, strings, arrays, and hash maps. It also treats functions as a first class citizen, allowing for higher order functions.

Example Code

The following is an implementation of the Fibonacci sequence.

let fib_aux = fn(target, sub_two, sub_one, counter) {
  if (target == counter) {
    sub_two + sub_one
  } else {
    fib_aux(target, sub_one, sub_one + sub_two, counter + 1)
  }
};
let fib = fn(x){
  if (x == 0) {
    0
  } else {
    if (x == 1) {
      1
    } else {
      fib_aux(x, 0, 1, 2)
    }
  }
};

About

The classic monkey interpreter, following the guide given in the writing an interpreter in go book

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages