aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2012-12-08 14:29:18 +0100
committerDrahflow <drahflow@gmx.de>2012-12-08 14:29:18 +0100
commit74f3f1354afe9b6fe866527a1de2a8d16d1210b8 (patch)
treeb98303d84e99ab1829410ae38317c27c911217b5 /examples
Initial commit
Diffstat (limited to 'examples')
-rw-r--r--examples/non-working/.io.ey.swpbin0 -> 12288 bytes
-rw-r--r--examples/non-working/cat.ey13
-rw-r--r--examples/non-working/cross.ey1
-rw-r--r--examples/non-working/io.ey3
-rw-r--r--examples/non-working/macro.ey8
-rw-r--r--examples/non-working/tokens.ey5
-rw-r--r--examples/working/abstract-right.ey1
-rw-r--r--examples/working/array_assign.ey4
-rw-r--r--examples/working/arrays.ey30
-rw-r--r--examples/working/complex-exec.ey3
-rw-r--r--examples/working/concat.ey15
-rw-r--r--examples/working/dom.ey4
-rw-r--r--examples/working/each.ey1
-rw-r--r--examples/working/exec.ey4
-rw-r--r--examples/working/fib.ey16
-rw-r--r--examples/working/fold.ey17
-rw-r--r--examples/working/grep.ey23
-rw-r--r--examples/working/loop.ey1
-rw-r--r--examples/working/recursion.ey6
-rw-r--r--examples/working/scope.ey11
-rw-r--r--examples/working/testing.ey11
21 files changed, 177 insertions, 0 deletions
diff --git a/examples/non-working/.io.ey.swp b/examples/non-working/.io.ey.swp
new file mode 100644
index 0000000..661a09e
--- /dev/null
+++ b/examples/non-working/.io.ey.swp
Binary files differ
diff --git a/examples/non-working/cat.ey b/examples/non-working/cat.ey
new file mode 100644
index 0000000..23b5786
--- /dev/null
+++ b/examples/non-working/cat.ey
@@ -0,0 +1,13 @@
+#!/usr/bin/env elymas
+
+/stdlib import
+
+4096 malloc =buf
+0 =len
+
+0 \argv 0 open =f
+{
+ f buf 4096 read =len
+ f buf len write
+} len while
+f close
diff --git a/examples/non-working/cross.ey b/examples/non-working/cross.ey
new file mode 100644
index 0000000..65a2923
--- /dev/null
+++ b/examples/non-working/cross.ey
@@ -0,0 +1 @@
+[ 1 2 3 ] [ 1 2 3 ] add dump
diff --git a/examples/non-working/io.ey b/examples/non-working/io.ey
new file mode 100644
index 0000000..24803bc
--- /dev/null
+++ b/examples/non-working/io.ey
@@ -0,0 +1,3 @@
+"io.ey" linux .ORDONLY 0 linux .open /fd defv
+
+fd linux .close
diff --git a/examples/non-working/macro.ey b/examples/non-working/macro.ey
new file mode 100644
index 0000000..9ead477
--- /dev/null
+++ b/examples/non-working/macro.ey
@@ -0,0 +1,8 @@
+{ * } /now defq
+
+{ { 1 2 3 add add } now } /f deff
+f dump
+
+{ blk 0 -01 * sym die } /qdie defq
+{ code die } /qcode defq
+{ f qcode }
diff --git a/examples/non-working/tokens.ey b/examples/non-working/tokens.ey
new file mode 100644
index 0000000..24ba14e
--- /dev/null
+++ b/examples/non-working/tokens.ey
@@ -0,0 +1,5 @@
+<
+ { dump } /a deff
+> /std defv
+
+"dump" std .a
diff --git a/examples/working/abstract-right.ey b/examples/working/abstract-right.ey
new file mode 100644
index 0000000..aa92ba3
--- /dev/null
+++ b/examples/working/abstract-right.ey
@@ -0,0 +1 @@
+0 3 range 5 add dump
diff --git a/examples/working/array_assign.ey b/examples/working/array_assign.ey
new file mode 100644
index 0000000..b369e5b
--- /dev/null
+++ b/examples/working/array_assign.ey
@@ -0,0 +1,4 @@
+[ 1 2 3 4 ] =a
+0 2 a =[]
+
+a dump
diff --git a/examples/working/arrays.ey b/examples/working/arrays.ey
new file mode 100644
index 0000000..2bf2431
--- /dev/null
+++ b/examples/working/arrays.ey
@@ -0,0 +1,30 @@
+#!/usr/bin/env elymas
+
+1 /testValue defv
+{ testValue and
+ _ /testValue defv
+ { } { "test failed" die } ? *
+} /test deff
+
+3 4 add
+ 7 eq test
+[ 4 7 ]
+ -00
+ 0 -01 * 4 eq test
+ 1 -01 * 7 eq test
+3 [ -0111 ]
+ -000
+ 0 -01 * 3 eq test
+ 1 -01 * 3 eq test
+ 2 -01 * 3 eq test
+1 [ 4 7 ] *
+ 7 eq test
+3 [ 4 7 ] add
+ -00
+ 0 -01 * 7 eq test
+ 1 -01 * 10 eq test
+[ 1 2 3 ] _0 add
+ -000
+ 0 -01 * 2 eq test
+ 1 -01 * 4 eq test
+ 2 -01 * 6 eq test
diff --git a/examples/working/complex-exec.ey b/examples/working/complex-exec.ey
new file mode 100644
index 0000000..fe17562
--- /dev/null
+++ b/examples/working/complex-exec.ey
@@ -0,0 +1,3 @@
+#!/usr/bin/env elymas
+
+3 { 2 add } |mul -21*20* dump
diff --git a/examples/working/concat.ey b/examples/working/concat.ey
new file mode 100644
index 0000000..982f598
--- /dev/null
+++ b/examples/working/concat.ey
@@ -0,0 +1,15 @@
+{ 2 add } /f deff
+{ 3 mul } /g deff
+
+1 f g dump
+1 { f g } * dump
+
+|f |g ; /h deff
+
+1 h dump
+
+{ /ff defv
+ { 1 2 3 } ff ; ff ;
+} /test deff
+
+|add test * dump
diff --git a/examples/working/dom.ey b/examples/working/dom.ey
new file mode 100644
index 0000000..1c66a34
--- /dev/null
+++ b/examples/working/dom.ey
@@ -0,0 +1,4 @@
+[ 7 7 7 7 7 ] dom dump
+<
+ { 7 } /dom deff
+> dom dump
diff --git a/examples/working/each.ey b/examples/working/each.ey
new file mode 100644
index 0000000..aff53cf
--- /dev/null
+++ b/examples/working/each.ey
@@ -0,0 +1 @@
+{ =i i dump } [ 1 2 3 ] each
diff --git a/examples/working/exec.ey b/examples/working/exec.ey
new file mode 100644
index 0000000..3d67793
--- /dev/null
+++ b/examples/working/exec.ey
@@ -0,0 +1,4 @@
+#!/usr/bin/env elymas
+
+1 1 |dump *0 add dump
+4 { 1 add } 3 rep dump
diff --git a/examples/working/fib.ey b/examples/working/fib.ey
new file mode 100644
index 0000000..96e8b38
--- /dev/null
+++ b/examples/working/fib.ey
@@ -0,0 +1,16 @@
+#!/usr/bin/env elymas
+
+{ ? * } /if deff
+
+{
+ _0 0 eq _1 1 eq add
+ { - 1 }
+ {
+ _0 1 sub "fib" | *
+ -01 2 sub "fib" | *
+ add
+ }
+ if
+} /fib deff
+
+7 fib dump
diff --git a/examples/working/fold.ey b/examples/working/fold.ey
new file mode 100644
index 0000000..4cae734
--- /dev/null
+++ b/examples/working/fold.ey
@@ -0,0 +1,17 @@
+{ =f =a a len =l
+ l {
+ 0 a *
+ 1 l 1 sub range { a * f * } each
+ } { "fold on empty array" die }
+ ? *
+} /fold deff
+
+{ =f _ len =l l dearray f l 1 sub rep } /foldshort deff
+
+{ =f { f fold } } /enfold deff
+
+[ 1 2 3 ]
+_ |add fold dump
+_ |add foldshort dump
+_ |add enfold * dump
+-
diff --git a/examples/working/grep.ey b/examples/working/grep.ey
new file mode 100644
index 0000000..2c94847
--- /dev/null
+++ b/examples/working/grep.ey
@@ -0,0 +1,23 @@
+{ /p deff {
+ [ -01 { _ p { } { - } ? * } each ]
+} } /engrep deff
+
+{ engrep * } /grep deff
+{ -110 ; engrep |dom -20*1* } /indices deff
+
+{ /p deff _ /a deff len /l defv
+ 1 neg /r defv
+
+ 0 {
+ _ l lt 1 neg r eq and
+ } {
+ _ a p { _ =r } { } ? *
+ 1 add
+ } loop -
+ r
+} /index deff
+
+[ 1 2 3 4 5 6 7 8 9 ] { 2 mod } grep dump
+[ 1 3 4 5 6 7 8 9 ] { 2 mod } indices dump
+[ 1 3 4 5 6 7 8 9 ] { 6 eq } index dump
+[ 0 0 0 1 0 0 1 1 ] { } indices dump
diff --git a/examples/working/loop.ey b/examples/working/loop.ey
new file mode 100644
index 0000000..a82688c
--- /dev/null
+++ b/examples/working/loop.ey
@@ -0,0 +1 @@
+50 { _ 30 gt } { _ dump 1 sub } loop dump
diff --git a/examples/working/recursion.ey b/examples/working/recursion.ey
new file mode 100644
index 0000000..1c05c5c
--- /dev/null
+++ b/examples/working/recursion.ey
@@ -0,0 +1,6 @@
+5
+{ exe =e
+ 1 sub
+ _ dump
+ _ { e * } { } ? *
+} *
diff --git a/examples/working/scope.ey b/examples/working/scope.ey
new file mode 100644
index 0000000..adf7725
--- /dev/null
+++ b/examples/working/scope.ey
@@ -0,0 +1,11 @@
+#!/usr/bin/env elymas
+
+<
+ 1 /a defv
+ 2 /b defv
+ { "yes" dump } /c deff
+>
+
+_00 .a dump
+ .b dump
+ .c
diff --git a/examples/working/testing.ey b/examples/working/testing.ey
new file mode 100644
index 0000000..76ddf94
--- /dev/null
+++ b/examples/working/testing.ey
@@ -0,0 +1,11 @@
+#!/usr/bin/env elymas
+
+1 /testValue defv
+{ testValue and
+ _ /testValue defv
+ { } { "test failed" die } ? *
+} /test deff
+
+1 test
+1 test
+0 test