ZVON > References > Haskell reference |
Intro / Search / ZVON |
| Indexes | >> Syntax << | Prelude | Ratio | Complex | Numeric | Ix | Array | List | Maybe | Char | Monad | IO | Directory | System | Time | Locale | CPUTime | Random |
Name | As-patterns |
---|---|
Description | assigns matched pattern after "@" to the symbol before "@" so that this symbol can be used in the right-hand side expression |
Related: | |
Bibliography: | Case Expressions and Pattern Matching [ A Gentle Introduction to Haskell ] |
Program source: main = print (aaa [2,3,4]) aaa y@(x:xs) = x:y
Output: [2,2,3,4]
Program source: main = print (aaa (True,12,6)) aaa p@(x,y,z) = if x then show p ++ ": " ++ show(y+z) else ""
Output: "(True,12,6): 18"