https://github.com/trizen/island
The Island programming language. (unimplemented idea)
https://github.com/trizen/island
Last synced: 3 months ago
JSON representation
The Island programming language. (unimplemented idea)
- Host: GitHub
- URL: https://github.com/trizen/island
- Owner: trizen
- License: gpl-3.0
- Created: 2016-09-24T14:25:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-24T16:56:42.000Z (over 9 years ago)
- Last Synced: 2025-03-03T02:28:29.396Z (over 1 year ago)
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Island
The Island programming language is a an experimental project for a uniformly design programming language.
The main features of the language include:
* Prefix notation
* Multiple dispatch
* Higher-order functions
* Uniformity and simplicity
### Examples
The following examples illustrate some of the decisions made in designing the syntax of the language.
#### Factorial
```python
def fac { |n|
if [eq n 0] [ return 1 ]
mul n (call fac (sub n 1))
}
say (call fac 10) #=> 3628800
```
#### Fibonacci
```python
def fib { |n|
if [lt n 2] [ return n ]
add (call fib (sub n 1)) (call fib (sub n 2))
}
say (call fib 12) #=> 144
```
#### Bernoulli numbers (recursive)
```ruby
def bern_helper { |n k|
mul (call binomial n k) (div (call bernoulli_number k) (add (sub n k) 1))
}
def bern_diff { |n k d|
if [lt n k] [ return d ]
call bern_diff n (add k 1) (sub d (call bern_helper (add n 1) k))
}
def bernoulli_number { |n|
if [one? n] [ return (div 1 2) ]
if [odd? n] [ return 0 ]
if [gt n 0] [ return (call bern_diff (sub n 1) 0 1) ]
return 1
}
for (range 0 25) { |i|
def num (call bernoulli_number i)
unless [zero? num] [
printf "B(%2d) = %20s / %s\n" i (nu num) (de num)
]
}
```
#### `while`-loop
Multimethod: `while(Expr, Expr)`
```python
def n 10
while [gt n 0] [
say n
sub! n 1
]
```
#### `foreach`-loop
Multimethod: `for(Range, Block)`
```python
for (range 1 10) { |n|
say n
}
```
#### `for(;;)`-loop
Multimethod: `for(Expr, Expr, Expr, Expr)`
```python
for [def n 1] [lt n 10] [add! n 1] [
say n
]
```