Skip to content
Permalink
Browse files

all non-functional, non-complex commands implemented

  • Loading branch information...
Mego committed Nov 9, 2015
1 parent 95c3f76 commit 6d8efc6d2a4ef14979b500e3b48cb5bb266e3873
Showing with 16 additions and 6 deletions.
  1. +9 −1 commands.py
  2. +7 −5 commands.txt
@@ -165,6 +165,13 @@ def dupe_each_fn(srs):
tmp.append(a)
tmp.append(a)
srs.stack=tmp[:]

def r_fn(srs):
a=srs.pop()
if type(a) is StringType:
map(srs.push,a.split('')[::-1])
elif type(a) in [IntType, LongType]:
srs.push(range(a))

fn_table={32:lambda x:x.push(len(x.stack)),
33:lambda x:x.push(math.factorial(x.pop())),
@@ -191,6 +198,7 @@ def dupe_each_fn(srs):
75:lambda x:x.push(ceil(x.pop())),
76:lambda x:x.push(floor(x.pop())),
80:lambda x:x.push(nth_prime(x.pop())),
82:lambda x:x.push(range(1,x.pop()+1)),
83:lambda x:x.push(math.sin(x.pop())),
84:lambda x:x.push(math.tan(x.pop())),
85:lambda x:x.push(list(set(x.pop()).union(x.pop()))),
@@ -214,7 +222,7 @@ def dupe_each_fn(srs):
111:psh_fn,
112:p_fn,
113:enq_fn,
114:lambda x:map(x.push,x.pop().split('')[::-1]),
114:r_fn,
115:lambda x:x.push(math.sgn(x.pop())),
116:flat_explode_fn,
122:lambda x:map(x.eval,(lambda y:['.' for _ in range(y)])(x.pop())),
@@ -98,7 +98,8 @@ If the -e flag is passed, consecutive runs of characters in [a-zA-Z0-9.,'"() ] a
80 (P): pop a: push the a-th prime (zero-indexed)
81 (Q): if stack is empty: print the program's source code to stdout
82 (R): pop �,[a]: call �, using [a] as a temporary stack, push [a] (similar to reduce(�,[a]))
pop "a", push reverse("a")
pop "a": push reverse("a")
pop a: push [1,2,...,a] (range(1,a+1))
83 (S): pop a: push sin(a)
84 (T): pop a: push tan(a)
85 (U): pop [a],[b]: push union of [a] and [b]
@@ -134,7 +135,8 @@ If the -e flag is passed, consecutive runs of characters in [a-zA-Z0-9.,'"() ] a
112 (p): pop a: push 1 if a is prime else 0
pop [a]: pop b from [a], push [a],b
113 (q): pop [a],b: enqueue b in [a], push [a]
114 (r): pop "a"; push each character in "a", starting from the end (explode string)
114 (r): pop "a": push each character in "a", starting from the end (explode string)
pop a: push [0,1,...,a-1] (range(0,a))
115 (s): pop a: push sgn(a)
116 (t): pop all elements from stack, flatten any lists and explode any strings, and push them in the same order they were popped (full stack flatten/explode)
117 (u):
@@ -146,7 +148,7 @@ If the -e flag is passed, consecutive runs of characters in [a-zA-Z0-9.,'"() ] a
123 ({): pop a: rotate stack right a times
124 (|): pop a,b: push (a | b)
125 (}): pop a: rotate stack left a times
126 (~): pop a: push ~a (unary negate)
126 (~): pop a: push ~a (unary bitwise negate)
127 (): terminate the program
128 (�): pop a,b: push a+ib
129 (�): pop entire stack and print to stdout
@@ -176,7 +178,7 @@ If the -e flag is passed, consecutive runs of characters in [a-zA-Z0-9.,'"() ] a
153 (�):
154 (�):
155 (�): pop a,b: push abs(a)*sgn(b)
156 (�): pop �,a: fix first argument of � to a, decrease �'s arity by one, push � (partial(�,a))
156 (�):
157 (�):
158 (�): pop z: push phase(z)
159 (�): pop �: call �
@@ -261,7 +263,7 @@ If the -e flag is passed, consecutive runs of characters in [a-zA-Z0-9.,'"() ] a
238 (�):
239 (�): pop [a],[b]: push intersection of [a] and [b]
240 (�):
241 (�): pop a: push 0-a
241 (�): pop a: push -a (unary negate)
242 (�): pop a,b: push a>=b
243 (�): pop a,b: push a<=b
244 (�):

0 comments on commit 6d8efc6

Please sign in to comment.
You can’t perform that action at this time.