Personal tools

Cum scriem "declaratii locale" in interiorul unor functii ?

From HaskellWiki

Revision as of 18:20, 28 November 2006 by Ha$kell (Talk | contribs)

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

Se poate folosi o expresie cu let, desi nu e singura solutie:

Exemplul 1:
  let f = (\x -> x +1)
  in f 2

Entitatile declarate local si folosite in expresie pot fi obtinute si in urma unei potriviri de sabloane ("pattern matching"):

Exemplul 2:
  let (a,b) = ( [1,2] , [3] )
  in a ++ b