This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
split :: Eq a => a -> [a] -> [[a]] | |
split _ [] = [[]] | |
split delim str = | |
let (before, remainder) = span (/= delim) str | |
in before:case remainder of | |
[] -> [] | |
x -> split delim $ tail x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- check the multiplicative persistence of a given number | |
-- https://www.youtube.com/watch?v=Wim9WJeDTHQ&list=PLt5AfwLFPxWKuRpivZd_ivR2EvEzKrDUu&index=2 | |
-- https://oeis.org/A003001 | |
import System.Environment(getArgs) | |
import Data.List(intercalate) | |
main = do | |
args <- getArgs | |
let n = read (head args) :: Integer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
digits :: Int -> [Int] | |
digits x = reverse $ revDigits x | |
revDigits :: Int -> [Int] | |
revDigits 0 = [] | |
revDigits x = x `mod` 10 : revDigits (x `div` 10) |
NewerOlder