Personal tools

Programati si zambiti !

From HaskellWiki

Revision as of 15:48, 19 January 2008 by Ha$kell (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Prelude> ( \ (+) -> 1 +2 ) (-) -1 Prelude> ( \ x -> x 1 2 ) (-) -1 Prelude> ( \ x -> x 1 2 ) (-) -1 Prelude> ( \ ($) x y -> y $ x ) (+) 1 2 3 Prelude> let (+) = (*) in 2 + 3 6 Prelude>


Prelude> :t ($ ($) ) flip ($) ($) :: (((a -> b) -> a -> b) -> c) -> c Prelude> :t (. (.) ) flip (.) (.) :: (((a -> b) -> a -> c) -> d) -> (b -> c) -> d Prelude> :t ((.). ) ((.) .) :: (a -> b -> c) -> a -> (d -> b) -> d -> c Prelude> :t $ ERROR - Syntax error in expression (unexpected symbol "$") Prelude> :t ($) ($) :: (a -> b) -> a -> b


let (/) = (\ x y -> 10 * x + y) in 3/5 35

let (//) = (\ a b -> 8 * a + b) in 7//1 57

let (#) = (\ a b -> 8 * a + b) in 7#1 57

Nu incercati cu (*) !!

Baza8> foldl (\ a b -> 8 * a + b) 0 $ map (\ a -> ord a - ord '0') "74" 60 Baza8>

Baza8> let (+) = (*) in 2 + 3 6