Difference between revisions of "Cum scriu bucla while din functia principala, main ?"
m |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:Ro]] |
||
⚫ | |||
+ | |||
+ | |||
+ | <center> http://www.haskell.org/wikiupload/b/b7/Basescu.jpg |
||
+ | |||
+ | |||
+ | 2009 : Presedintele Basescu doreste elevilor examene corecte si profesori exigenti ! |
||
+ | (captura de la TV) |
||
+ | </center> |
||
+ | ---- |
||
+ | |||
⚫ | |||
<haskell> |
<haskell> |
||
Line 33: | Line 44: | ||
+ | {-- |
||
− | {--Reading file "input.hs": |
||
runhugs myinput.hs |
runhugs myinput.hs |
||
--} |
--} |
||
</haskell> |
</haskell> |
||
+ | |||
+ | Atentie, folosirea acestui while poate pune unele probleme motiv pentru care recomandam sa scrieti actiunea '''main''' a unui program in Haskell in maniera recursiva. |
||
+ | |||
+ | |||
+ | ---- |
||
+ | <center> |
||
+ | http://www.haskell.org/wikiupload/2/2c/BannerProLinuxAndHaskell.gif |
||
+ | |||
+ | La facultate poti invata unul din cele mai productive limbaje: Haskell ! |
||
+ | </center> |
||
+ | ---- |
||
+ | Pagina indexata la indexul [[Category:Ro]] [http://www.haskell.org/haskellwiki/Category:Ro Categories:Ro] |
||
+ | ---- |
||
+ | [http://www.haskell.org/haskellwiki/Ro/Haskell <= Inapoi la pagina principala Ro/Haskell. ]<br> <br> |
||
+ | [http://www.haskell.org/haskellwiki/Intrebarile_incepatorului <'''-''' Inapoi la Intrebarile incepatorului Ro/Haskell. ] |
Latest revision as of 13:58, 10 February 2011
2009 : Presedintele Basescu doreste elevilor examene corecte si profesori exigenti !
(captura de la TV)
Atunci cand programul principaL PRELUCREAZA UN FLUX DE DATE iar functia principala s-ar fi scris ca o bucla while intr-un limbaj imperativ este posibil sa aveti nevoie de acest while. El este scris in do-notatie si se foloseste de obicei impreuna cu operatii de IO.
while test actiune
= do rezultat <- test
if rezultat then do actiune
while test actiune
else return ()
Exemplu:
module Main where
import IO
-- pentru isEOF
-- isEOF :: IO Bool
while test actiune
= do rezultat <- test
if rezultat then do actiune
while test actiune
else return ()
main= while (do b <- isEOF
return (not b) )
(do s <- getChar
print $ ord s )
{--
runhugs myinput.hs
--}
Atentie, folosirea acestui while poate pune unele probleme motiv pentru care recomandam sa scrieti actiunea main a unui program in Haskell in maniera recursiva.
La facultate poti invata unul din cele mai productive limbaje: Haskell !
Pagina indexata la indexul Categories:Ro
<= Inapoi la pagina principala Ro/Haskell.
<- Inapoi la Intrebarile incepatorului Ro/Haskell.