aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/schellingcoin/quicksort.se
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/schellingcoin/quicksort.se')
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/schellingcoin/quicksort.se33
1 files changed, 33 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/schellingcoin/quicksort.se b/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/schellingcoin/quicksort.se
new file mode 100644
index 000000000..be5d97fc7
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/schellingcoin/quicksort.se
@@ -0,0 +1,33 @@
+def kall():
+ argcount = ~calldatasize() / 32
+ if argcount == 1:
+ return(~calldataload(1))
+
+ args = array(argcount)
+ ~calldatacopy(args, 1, argcount * 32)
+ low = array(argcount)
+ lsz = 0
+ high = array(argcount)
+ hsz = 0
+ i = 1
+ while i < argcount:
+ if args[i] < args[0]:
+ low[lsz] = args[i]
+ lsz += 1
+ else:
+ high[hsz] = args[i]
+ hsz += 1
+ i += 1
+ low = self.kall(data=low, datasz=lsz, outsz=lsz)
+ high = self.kall(data=high, datasz=hsz, outsz=hsz)
+ o = array(argcount)
+ i = 0
+ while i < lsz:
+ o[i] = low[i]
+ i += 1
+ o[lsz] = args[0]
+ j = 0
+ while j < hsz:
+ o[lsz + 1 + j] = high[j]
+ j += 1
+ return(o, argcount)