Useless instructions: Difference between revisions

Add Factor
No edit summary
(Add Factor)
Line 164:
Nigel Galloway
</pre>
 
=={{header|Factor}}==
Factor uses a data stack to pass arguments to functions. Factor provides at least five ways to arrange the stack, all five of which can make the other four redundant.
 
To get the data stack from <code>1 2 3</code> to <code>1 2 2 3 1</code> we could:
 
Use stack shuffle words:
 
<lang factor>dupd reach</lang>
 
Use data flow combinators:
 
<lang factor>[ ] keepdd [ [ ] [ ] bi ] 2dip</lang>
 
Use local variables:
 
<lang factor>[let :> ( a b c ) a b b c a ]</lang>
 
Use dynamic variables:
 
<lang factor>SYMBOLS: a b c ;
c set b set a set a get b get b get c get a get</lang>
 
Use <code>shuffle(</code> syntax:
 
<lang factor>shuffle( a b c -- a b b c a )</lang>
 
=={{header|Go}}==
I can't recall any language features or standard library methods in Go which are completely redundant either by design or due to subsequent developments. Moreover, the compiler does a lot to prevent unintentional redundancy by flagging unused packages, unused variables and unreachable code.
1,808

edits