diff options
| author | Drahflow <drahflow@gmx.de> | 2012-12-10 14:30:07 +0100 |
|---|---|---|
| committer | Drahflow <drahflow@gmx.de> | 2012-12-10 14:30:07 +0100 |
| commit | 26c5b2be3918e7e27f9ae0616f3a3a629190b19c (patch) | |
| tree | 9fe1e3b4631e460acbc5d92c62dab176cfdca5a5 | |
| parent | 9de23daca3f223643eb4d0f92636d72d0f5c9364 (diff) | |
Quicksort
| -rw-r--r-- | examples/non-working/cat.ey | 13 | ||||
| -rw-r--r-- | examples/non-working/tokens.ey | 5 | ||||
| -rw-r--r-- | examples/working/cat.ey | 7 | ||||
| -rw-r--r-- | examples/working/macro.ey (renamed from examples/non-working/macro.ey) | 0 | ||||
| -rw-r--r-- | examples/working/qsort.ey | 23 | ||||
| -rw-r--r-- | interpreter/Elymas.pm | 2 |
6 files changed, 31 insertions, 19 deletions
diff --git a/examples/non-working/cat.ey b/examples/non-working/cat.ey deleted file mode 100644 index 23b5786..0000000 --- a/examples/non-working/cat.ey +++ /dev/null @@ -1,13 +0,0 @@ -#!/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/tokens.ey b/examples/non-working/tokens.ey deleted file mode 100644 index 24ba14e..0000000 --- a/examples/non-working/tokens.ey +++ /dev/null @@ -1,5 +0,0 @@ -< - { dump } /a deff -> /std defv - -"dump" std .a diff --git a/examples/working/cat.ey b/examples/working/cat.ey new file mode 100644 index 0000000..45f354d --- /dev/null +++ b/examples/working/cat.ey @@ -0,0 +1,7 @@ +#!/usr/bin/env elymas + +1 { } { + 4096 sys .in .read + _ sys .out .writeall + len +} loop diff --git a/examples/non-working/macro.ey b/examples/working/macro.ey index fdaf0cf..fdaf0cf 100644 --- a/examples/non-working/macro.ey +++ b/examples/working/macro.ey diff --git a/examples/working/qsort.ey b/examples/working/qsort.ey new file mode 100644 index 0000000..c7bf93c --- /dev/null +++ b/examples/working/qsort.ey @@ -0,0 +1,23 @@ +[ 23 3 43 37 89 11 21 4 35 94 28 36 96 95 51 7 59 57 48 68 85 73 6 67 71 92 76 14 31 18 64 30 9 41 34 86 33 75 70 81 27 93 8 100 55 39 1 61 42 45 29 5 17 79 13 90 49 99 91 69 46 54 16 53 40 62 60 20 88 97 12 74 15 65 72 80 50 44 47 24 25 2 58 52 78 83 10 84 98 19 56 87 26 32 22 63 82 77 0 38 66 ] /data defv + +{ "=[]" | -31*21*310*210* } /swap deff + +{ /a defv /end defv /start defv + end a * /pivot defv + start /store defv + + start end 1 sub range { /i defv + i a * pivot lt { + store _ i a swap + 1 add =store + } rep + } each + + store _ end a swap + _ 1 sub start -0101 lt { a qsort } { -- } ? * + 1 add end -1010 lt { a qsort } { -- } ? * +} /qsort deff + +{ _ len _ 0 gt { 1 sub 0 -012 qsort } rep } /sort deff + +data _ sort dump diff --git a/interpreter/Elymas.pm b/interpreter/Elymas.pm index 4f58c2b..22199b7 100644 --- a/interpreter/Elymas.pm +++ b/interpreter/Elymas.pm @@ -7,7 +7,7 @@ require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw( popInt popString popArray enstruct arrayAccess $quoted @globalCallStack - interpretCode execute executeString executeFile resolve + interpretCode execute executeString executeFile resolve canCastTo ); use Data::Dumper; |
