Rep-string: Difference between revisions
Content added Content deleted
(Crystal code) |
m (→{{header|AppleScript}}: Minor tidying) |
||
Line 172: | Line 172: | ||
=={{header|AppleScript}}== |
=={{header|AppleScript}}== |
||
<lang AppleScript> |
<lang AppleScript>------------------------REP-CYCLES------------------------- |
||
-- repCycles :: String -> [String] |
-- repCycles :: String -> [String] |
||
Line 199: | Line 199: | ||
---------------------------TEST---------------------------- |
|||
on run |
on run |
||
set samples to {"1001110011", "1110111011", "0010010010", ¬ |
set samples to {"1001110011", "1110111011", "0010010010", ¬ |
||
Line 206: | Line 206: | ||
unlines(cons("Longest cycle:" & linefeed, ¬ |
unlines(cons("Longest cycle:" & linefeed, ¬ |
||
map |
map(intercalate(" -> "), ¬ |
||
map(cycleReport, samples)))) |
map(cycleReport, samples)))) |
||
Line 212: | Line 212: | ||
---------------------GENERIC FUNCTIONS--------------------- |
|||
-- concat :: [[a]] -> [a] | [String] -> String |
-- concat :: [[a]] -> [a] | [String] -> String |
||
Line 231: | Line 231: | ||
{x} & xs |
{x} & xs |
||
end cons |
end cons |
||
-- curry :: (Script|Handler) -> Script |
|||
on curry(f) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
|λ|(a, b) of mReturn(f) |
|||
end |λ| |
|||
end script |
|||
end |λ| |
|||
end script |
|||
end curry |
|||
-- filter :: (a -> Bool) -> [a] -> [a] |
-- filter :: (a -> Bool) -> [a] -> [a] |
||
Line 293: | Line 280: | ||
-- intercalate :: Text -> [Text] -> Text |
-- intercalate :: Text -> [Text] -> Text |
||
on intercalate(strText |
on intercalate(strText) |
||
⚫ | |||
⚫ | |||
on |λ|(xs) |
|||
set my text item delimiters to |
set {dlm, my text item delimiters} to {my text item delimiters, strText} |
||
set strJoined to xs as text |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end intercalate |
end intercalate |
||
Line 410: | Line 401: | ||
-- unlines :: [String] -> String |
-- unlines :: [String] -> String |
||
on unlines(xs) |
on unlines(xs) |
||
intercalate(linefeed |
|λ|(xs) of intercalate(linefeed) |
||
end unlines</lang> |
end unlines</lang> |
||
{{Out}} |
{{Out}} |