Set right-adjacent bits: Difference between revisions

Added Easylang
(added RPL)
(Added Easylang)
Line 438:
Result: 011110000000111100000011110000011110000111100011110011110111111111
</pre>
 
=={{header|EasyLang}}==
{{trans|Java}}
<syntaxhighlight>
proc adjacent txt$ n . .
print "n = " & n & ", width = " & len txt$
print "input: " & txt$
txt$[] = strchars txt$
res$[] = txt$[]
for i to len res$[]
if txt$[i] = "1"
for j = i + 1 to lower (i + n) len res$[]
res$[j] = "1"
.
.
.
res$ = strjoin res$[]
print "result: " & res$
print ""
.
adjacent "1000" 2
adjacent "0100" 2
adjacent "0010" 2
adjacent "0000" 2
test$ = "010000000000100000000010000000010000000100000010000010000100010010"
adjacent test$ 0
adjacent test$ 1
adjacent test$ 2
adjacent test$ 3
</syntaxhighlight>
 
=={{header|F_Sharp|F#}}==
2,063

edits