Skip to content

Instantly share code, notes, and snippets.

View cacharle's full-sized avatar

Charles Cabergs cacharle

View GitHub Profile
@cacharle
cacharle / split.hs
Created August 19, 2019 16:25 — forked from ifukazoo/split.hs
split
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
-- 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
digits :: Int -> [Int]
digits x = reverse $ revDigits x
revDigits :: Int -> [Int]
revDigits 0 = []
revDigits x = x `mod` 10 : revDigits (x `div` 10)