Personal tools

Cum poate fi definit sequence ?

From HaskellWiki

Revision as of 21:45, 25 January 2008 by Ha$kell (Talk | contribs)

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


sequence_ transforma o lista de actiuni de IO () (sau alte actiuni monadice) intr-o singura actiune compusa. Ati putea face in C asa ceva ? Adica ati putea face in C o functie care transforma o lista de instructiuni intr-un bloc ?

1) In do-notatie, in mod recursiv, sequence_ ar putea fi definit ca:

sequence_         :: [ IO() ] -> IO ()
sequence_  []     = return ()
sequence_  (a:as) = do a
                       sequence_ as

2) Vazut ca un foldr ar putea fi definit ca:

sequence_ = foldr (>>) (return () )

Pagina indexata la indexul Categories:Ro


<= Inapoi la pagina principala Ro/Haskell.

<- Inapoi la Intrebarile incepatorului Ro/Haskell.