Look-and-say sequence: Difference between revisions

Add Miranda
(Added XPL0 example.)
(Add Miranda)
Line 3,117:
end</syntaxhighlight>
 
=={{header|Miranda}}==
<syntaxhighlight lang="miranda">main :: [sys_message]
main = [Stdout (lay (take 15 (iterate looksay "1")))]
 
looksay :: [char]->[char]
looksay = concat . map f . split
where f xs = show (#xs) ++ [hd xs]
 
split :: [*]->[[*]]
split = foldr f []
where f x [] = [[x]]
f x (ys:yss) = (x:ys):yss, if x = hd ys
= [x]:ys:yss, otherwise</syntaxhighlight>
{{out}}
<pre>1
11
21
1211
111221
312211
13112221
1113213211
31131211131221
13211311123113112211
11131221133112132113212221
3113112221232112111312211312113211
1321132132111213122112311311222113111221131221
11131221131211131231121113112221121321132132211331222113112211
311311222113111231131112132112311321322112111312211312111322212311322113212221</pre>
=={{header|MiniScript}}==
<syntaxhighlight lang="miniscript">// Look and Say Sequence
2,094

edits