Rep-string: Difference between revisions

Add Miranda
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
(Add Miranda)
Line 2,490:
It outputs all the possibilities for a rep-string,
if there is no rep-string it will show an empty list {}.
 
=={{header|Miranda}}==
<syntaxhighlight lang="miranda">main :: [sys_message]
main = [Stdout (lay (map test tests))]
 
test :: [char]->[char]
test s = s ++ ": " ++ show (repstrings s)
 
tests :: [[char]]
tests = ["1001110011", "1110111011", "0010010010", "1010101010",
"1111111111", "0100101101", "0100100", "101", "11", "00",
"1"]
 
repstrings :: [*]->[[*]]
repstrings s = filter matching bases
where bases = [take n s | n<-[1..#s div 2]]
matching r = s = take (#s) (concat (repeat r))</syntaxhighlight>
{{out}}
<pre>1001110011: ["10011"]
1110111011: ["1110"]
0010010010: ["001"]
1010101010: ["10","1010"]
1111111111: ["1","11","111","1111","11111"]
0100101101: []
0100100: ["010"]
101: []
11: ["1"]
00: ["0"]
1: []</pre>
 
=={{header|Modula-2}}==
2,114

edits