Skip to content

Commit 71d4ed3

Browse files
EO Sample Examples
1 parent 444ec35 commit 71d4ed3

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

eo-sample-codes/app.eo

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
+package sandbox
2+
+alias sandbox.fibonacci
3+
+alias org.eolang.io.stdout
4+
+alias org.eolang.txt.sscanf
5+
# +alias org.eolang.txt.sprintf
6+
7+
[args...] > app
8+
stdout > @
9+
sprintf
10+
"%dth Fibonacci number is %d\n"
11+
(sscanf "%d" (args.at 0)).at 0 > n
12+
fibonacci n
13+

eo-sample-codes/fibonacci.eo

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
+package sandbox
2+
3+
[n] > fibonacci
4+
if. > @
5+
n.lt 3
6+
small n
7+
rec n 1 1
8+
9+
[n] > small
10+
if. > @
11+
n.eq 2
12+
1
13+
n
14+
15+
[n minus1 minus2] > rec
16+
if. > @
17+
n.eq 3
18+
minus1.plus minus2
19+
rec (n.minus 1) (minus1.plus minus2) minus1

eo-sample-codes/hello.eo

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[args...] > hello
2+
QQ.io.stdout > @
3+
"Hello, world!\n"

eo-sample-codes/iterator.eo

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[args...] > app
2+
memory 0 > x
3+
seq > @
4+
x.write 2
5+
while.
6+
x.lt 6
7+
[i]
8+
seq > @
9+
QQ.io.stdout
10+
QQ.txt.sprintf
11+
"%d x %d = %d\n"
12+
x
13+
x
14+
x.times x
15+
x.write
16+
x.plus 1
17+
TRUE

0 commit comments

Comments
 (0)