1 f a c t x = x ∗ f a c t ( x − 1) Operadores son funciones 41 ∗ 200 ( ∗ ) 41 200 Funciones son operadores elem 2 [ 1 . . 1 0 ] 2 ‘elem ‘ [ 1 . . 1 0 ]
→ Char dv1 rut = l e t revRut = reverse rut revDigits = map digitToInt revRut f a c t o r s = cycle [ 2 . . 7 ] products = zipWith ( ∗ ) f a c t o r s revDigits sumOfProducts = sum products d i g i t = (11 − sumOfProducts ) ‘mod‘ 11 in digitToChar d i g i t where digitToChar 10 = ’k ’ digitToChar x = chr $ x + ord ’0 ’
Char dv2 rut = l e t revDigits = map digitToInt $ reverse rut products = zipWith ( ∗ ) ( cycle [ 2 . . 7 ] ) revDigits d i g i t = (11 − sum products ) ‘mod‘ 11 in ”0123456789k” ! ! d i g i t
: b → c ( f ◦ g ) : : a → c Currying zipWith : : ( a → b → c ) → [ a ] → [ b ] → [ c ] zipWith (+) : : (Num a ) ⇒ [ a ] → [ a ] → [ a ] zipWith (+) [ 1 . . 1 0 ] : : (Enum a , Num a ) ⇒ [ a ] → [ a ]
( Tree a ) ( Tree a ) deriving (Show, Read , Eq) singleton : : a → Tree a singleton x = Node x EmptyTree EmptyTree t r e e I n s e r t : : (Ord a ) ⇒ a → Tree a → Tree a t r e e I n s e r t x EmptyTree = singleton x t r e e I n s e r t x (Node a l e f t right ) | x == a = Node x l e f t right | x < a = Node a ( t r e e I n s e r t x l e f t ) right | x > a = Node a l e f t ( t r e e I n s e r t x right )
Good! http://learnyouahaskell.com/ Real World Haskell http://book.realworldhaskell.org/read/ Haskell Cafe http://news.gmane.org/gmane.comp.lang. haskell.cafe