Reverse a string: Difference between revisions
Content deleted Content added
m moved Reversing a string to Reverse a string |
Non-locals Forth version added |
||
Line 225:
2drop ;
s" testing" 2dup reverse type \ gnitset</lang>
This one doesn't require locals:
<lang forth>: reverse
2dup 1- chars over + \ save string, calculate addresses
begin
over over < \ as long we didn't pass the middle
while \ swap the characters
over c@ over c@ >r over c! over r> swap c!
1- swap 1+ swap \ increment pointers
repeat 2drop \ drop the addresses
;
s" testing" reverse type</lang>
=={{header|Fortran}}==
|