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.
- Host: GitHub
- URL: https://github.com/justdvnsh/egg-programming-language
- Owner: justdvnsh
- Created: 2018-03-08T12:50:46.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-21T07:59:06.000Z (almost 8 years ago)
- Last Synced: 2025-02-07T08:31:14.604Z (12 months ago)
- Topics: javascript, language-design, programming-language
- Language: JavaScript
- Size: 11.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
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
```