Look-and-say sequence: Difference between revisions
Content added Content deleted
(Added XPL0 example.) |
Not a robot (talk | contribs) (Add Miranda) |
||
Line 3,117: | Line 3,117: | ||
end</syntaxhighlight> |
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}}== |
=={{header|MiniScript}}== |
||
<syntaxhighlight lang="miniscript">// Look and Say Sequence |
<syntaxhighlight lang="miniscript">// Look and Say Sequence |