Simple Programming Challenge Day 1 - Haskell & Python

preview_player
Показать описание

This problem was taken from Cracking the Coding Interview 6th Edition.
Рекомендации по теме
Комментарии
Автор

Thanks for posting!

Note: len(set("harry")) == len(set(list("harry")))

gideonbuckwalter
Автор

Hey! Nice video, I was looking for a comparison between Python and Haskell. I'm fluent in python, I use it everyday professionally, however I'm just starting to learn Haskell for fun.
Obviously Haskell is a functional programming language whereas python is mostly imperative, with some functional elements.
But what are some non obvious differences? What are some cool things Haskell can do that Python can't?
That would make for an interesting video for many people I think.
Cheers man, take care ;)

davidm.johnston
Автор

uniqueChar [] = True
uniqueChar (x:xs) = not (x `elem` xs) && uniqueChar xs

Laotze
Автор

Cleaner solution:
uniqueChars :: String -> Bool
uniqueChars [] = True
uniqueChars (h:t) = (h `notElem` t) && (uniqueChars t)

bdeos