User:Stormneedle

From Rosetta Code
Some languages I know
Language Proficiency
BASIC uh...
C Faded
ColdFusion Experienced'
DCL Faded
JavaScript Faded
MUMPS Experienced
SQL Moderate

Shooting Yourself in the Foot

You shoot 583149 AK-47 Teflon-tipped, hollow-point, armor-piercing bullets into even-numbered toes on odd-numbered feet of everyone in the building -- with one line of code. Three weeks later you shoot yourself in the head rather than try to modify that line.

Iterative version

You'll have to implement the ^Shoot routine on your own. I'm assuming the count is right rather than checking it, and dispensing only 1 bullet per toe.

<lang MUMPS>S ^W("AK-47","AMMO")="Teflon-tipped,hollow-point,armor-piercing" F P=$O(^B("")):0:($D(^B(P))#10) F F=$O(^B(P,"")):0:'$D(^B(P,F))#10 F T=$O(^B(P,F,"")):0:('$D(^B(P,F,T))#10) S:('F#2)&(T#2) X=$$SHOOT(^W("AK-47"),^B(P,F,T),1) S P=$O(^B(P)) Q S F=$O(^B(P,F)) Q S T=$O(^B(P,F,T)) Q</lang>