An open API service indexing awesome lists of open source software.

https://github.com/justdvnsh/egg-programming-language

A general purpose high level mathematical and functional programming language created for fun.
https://github.com/justdvnsh/egg-programming-language

javascript language-design programming-language

Last synced: 10 months ago
JSON representation

A general purpose high level mathematical and functional programming language created for fun.

Awesome Lists containing this project

README

          

# Egg

A general purpose high level mathematical and functional programming language created for fun.

## Getting Started
```
clone the repository
```

### Prerequisites

What things you need to install the software and how to install them

```
Javascript
```

## Built With

* Javasciprt

## Contributing

Please read [CONTRIBUTING.md] for details on our code of conduct, and the process for submitting pull requests to us.

## Authors

* **Divyansh Dwivedi** - *Initial work*

See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.

## License

Currently this project is unclicensed

## Example

### Loop
```javascript
run("do(define(total, 0),",
" define(count, 1),",
" while(<(count, 11),",
" do(define(total, +(total, count)),",
" define(count, +(count, 1)))),",
" print(total))");
// -> 55
```

### Function
```javascript
run(`
do(define(plusOne, fun(a, +(a, 1))),
print(plusOne(10)))
`);
// → 11
```

```javascript
run(`
do(define(pow, fun(base, exp,
if(==(exp, 0),
1,
*(base, pow(base, -(exp, 1)))))),
print(pow(2, 10)))
`);
// → 1024
```

### Arrays
```javascript
run(`
do(define(sum, fun(array,
do(define(i, 0),
define(sum, 0),
while(<(i, length(array)),
do(define(sum, +(sum, element(array, i))),
define(i, +(i, 1)))),
sum))),
print(sum(array(1, 2, 3))))
`);
//-> 6
```

### Comments
```javascript
console.log(parse("# hello\nx"));
// → {type: "word", name: "x"}

console.log(parse("a # one\n # two\n()"));
// → {type: "apply",
// operator: {type: "word", name: "a"},
// args: []}
```

### Scope
```javascript
run(`
do(define(x, 4),
define(setx, fun(val, set(x, val))),
setx(50),
print(x))
`);
// → 50

//run(`set(quux, true)`);
// → Some kind of ReferenceError
```