Smarandache prime-digital sequence: Difference between revisions
Content added Content deleted
Line 666: | Line 666: | ||
smarandache :: [Integer] |
smarandache :: [Integer] |
||
smarandache = [2,3,5,7] <> s [2,3,5,7] >>= \x -> guard (isPrime x) >> [x] |
smarandache = [2,3,5,7] <> s [2,3,5,7] >>= \x -> guard (isPrime x) >> [x] |
||
⚫ | |||
where |
|||
s xs = r <> s r |
|||
⚫ | |||
nextSPDSTerms :: [Int] -> [(String, String)] |
nextSPDSTerms :: [Int] -> [(String, String)] |
||
Line 675: | Line 673: | ||
go _ _ [] = [] |
go _ _ [] = [] |
||
go c (x:xs) terms |
go c (x:xs) terms |
||
| c `elem` terms = (commas c, commas x) : go nextCount xs (tail terms) |
|||
| otherwise = go nextCount xs terms |
|||
where nextCount = succ c |
|||
commas :: Show a => a -> String |
commas :: Show a => a -> String |