Skip to content

Latest commit

 

History

History
22 lines (19 loc) · 561 Bytes

README.md

File metadata and controls

22 lines (19 loc) · 561 Bytes

An interpreter for the Monkey programming language, from the book Writing an Interpeter in Go.

Usage

cargo run to start the REPL. Try something like defining map:

>> let map = fn(arr, f) {
     let iter = fn(arr, accumulated) {
       if (len(arr) == 0) {
         accumulated
       } else {
         iter(rest(arr), push(accumulated, f(first(arr))));
       }
     };
     iter(arr, []);
   };
>> let a = [1, 2, 3, 4];
>> let double = fn(x) { x * 2 };
>> map(a, double)
[2, 4, 6, 8]