Generic swap: Difference between revisions

no edit summary
m (Removed redundant text)
No edit summary
Line 271:
 
ReadLock(a,b) functioned by reading ''a'' and writing its value to ''b'', but also, recovering the value that was in ''b'' which it returns as the result of the function - which is written to ''a'' by the assignment, completing the swap. The ReadLock part is "atomic" or not interruptable, so it is used in semaphores and the like, but was available for other use. It swapped a single word, so could swap types such as integers or floating-point numbers (single precision) thus being somewhat generic.
 
=={{header|Amazing Hopper}}==
<lang Amazing Hopper>
#include <flow.h>
 
DEF-MAIN(argv,argc)
DIM(10) AS-INT-RAND( 10, random array )
SET( single var, 0.5768 )
PRNL( "SINGLE VAR: ", single var, "\nRANDOM ARRAY: ", random array )
single var <-> random array
PRNL( "SINGLE VAR: ", single var, "\nRANDOM ARRAY: ", random array )
END
</lang>
{{out}}
<pre>
$ hopper swap.flw
SINGLE VAR: 0.5768
RANDOM ARRAY: 4,2,5,10,8,3,4,8,3,5
SINGLE VAR: 4,2,5,10,8,3,4,8,3,5
RANDOM ARRAY: 0.5768
$
</pre>
 
=={{header|AmigaE}}==
543

edits