Yeti
Joined 24 August 2022
m
meh
m (meh) |
|||
Line 4:
----
=DC/Questions/DROP=
=Primes/Python/FSOE=▼
TODO Drop top of stack without side effects
<pre>
# assume there is a value in x[1337], e.g. "gold"
[gold] 1337 :x
# "trash" on the stack:
[trash]
# push x[1337] to x-stack
1337;x Sx
# deposit TOS in x[1337]
1337:
# top of x-stack to x[1337]
Lx 1337:
1337 ;x
[Stack: ]PAP f
</pre>
{{out}}
<pre>
Stack:
gold
</pre>
Sigh!
Is there really no simpler way to drop the top of stack that works for strings and numbers and in all versions of Dc?
{{works with|Python|2.x}}
This is a sequentialised variant of the well known sieve method (ab)using a dictionary as sparse array.
|