Personal tools

Cum poate fi definit sequence ?

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m
 
m
Line 14: Line 14:
 
sequence_ = foldr (>>) (return () )
 
sequence_ = foldr (>>) (return () )
 
</haskell>
 
</haskell>
  +
  +
[http://www.haskell.org/haskellwiki/Ro/Haskell <= Inapoi la pagina principala Ro/Haskell ]

Revision as of 21:05, 5 January 2008

1) In do-notatie, in mod recursiv 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 () )

<= Inapoi la pagina principala Ro/Haskell