f 3 [1,11,111,1111,...]
gives [2,11,111,2222,...]
>>> toListOf (every 1) [0..4]
[0,1,2,3,4]
>>> toListOf (every 2) [0..4]
[0,2,4]
>>> toListOf (every 3) [0..4]
[0,3]
>>> itoListOf (every 2) "Hello"
[(0,'H'),(2,'l'),(4,'o')]
>>> [0..4] ^.. every 1
[0,1,2,3,4]
>>> [0..4] ^.. every 2
[0,2,4]
>>> [0..4] ^.. every 3
[0,3]
traverse
(or traversed
) you are focusing on every element
Hi there ,
i want to run a simple email sender with smtp from the Module :
Network.HaskellNet.SMTP.
The Modul is already installed. cabal list --installed tells this !!!
However, there is a compilation error that is asking for the Module :
Network.HaskellNet.Auth.
But cabal cannot FIND this module ! ANY IDEA WOULD HELP !
Here is the example code of the session :
import Network.HaskellNet.SMTP
import Network.HaskellNet.Auth
import qualified Data.Text.Lazy as T
main = doSMTP "your.smtp.server.com" $ \conn ->
authSucceed <- authenticate PLAIN "username" "password" conn
if authSucceed
then sendPlainTextMail "receiver@server.com" "sender@server.com" "subject" (T.pack "Hello! This is the mail body!") conn
else print "Authentication failed."
Here is the result of compilation with the right smtp data.
$ ghc -o sendmail_4 sendmail_4.hs
sendmail_4.hs:2:8:
Could not find module `Network.HaskellNet.Auth'
Use -v to see a list of the files searched for.
hans@mx1:~/Documents/Haskell
$
cabal has listed the following Network Module :
network installed version 2.4.1.2 , 2.6.3.3
isVowel :: Char -> Bool
isVowel x = x `elem` ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
isNotVowel :: Char -> Bool
isNotVowel x = not (isVowel x)
recursiveAlternateVowels :: String -> Bool -> Bool
recursiveAlternateVowels xs v = go xs v where
go [] _ = True
go (x:xs) True = isVowel x && go xs False
go (x:xs) False = isNotVowel x && go xs True
wordContainsAlternateVowels :: String -> Bool
wordContainsAlternateVowels [] = True
wordContainsAlternateVowels (x:xs)
| isVowel x = recursiveAlternateVowels ([x]++xs) True
| isNotVowel x = recursiveAlternateVowels ([x]++xs) False
isVowel :: Char -> Bool
isVowel = flip elem "aeiouAEIOU"
checkAlternate :: (a -> Bool) -> [a] -> Bool
checkAlternate p0 l = all id $ reverse bools
where bools = snd $ foldl (\(p, acc) c -> (not . p, p c : acc)) (p0, []) l
checkAlternateVowels :: String -> Bool
checkAlternateVowels = checkAlternate isVowel