Look-and-say sequence: Difference between revisions

m (→‎{{header|REXX}}: used a more idiomatic method instead of having the subroutine assume the first "number" in the sequence, used an index in the output sequence. -- ~~~~)
Line 1,403:
 
(* see http://oeis.org/A005341 *)</lang>
 
 
== {{header|Nimrod}} ==
<lang nimrod>proc NextInLookAndSaySequence (current: string): string =
assert(len(current) > 0)
Result = ""
var ch = current[0]
var count = 1
for i in countup(1, len(current)-1):
if current[i] != ch:
Result &= $count & ch
ch = current[i]
count = 1
else:
count += 1
Result &= $count & ch
 
proc LookAndSay (n = 10) =
var next = "1"
for i in countup(1, n):
next = NextInLookAndSaySequence(next)
echo next
LookAndSay()
</lang>
 
=={{header|Oz}}==
26

edits