Changes between Version 9 and Version 10 of ViewPatterns


Ignore:
Timestamp:
Jan 23, 2007 10:58:38 AM (7 years ago)
Author:
simonpj@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ViewPatterns

    v9 v10  
    2121The proposal introduces a new form of pattern, called a '''view pattern''' 
    2222Here are some function definitions using view patterns. 
    23 To read these definitions, imagine that `$sing` is 
     23To read these definitions, imagine that `sing` is 
    2424a sort of constructor that matches singleton lists. 
    2525{{{ 
     
    3434 
    3535  h :: [[Int]] -> Int    
    36   h ($sing -> x : $sing -> y : _) = x+y 
     36  h (sing -> x : sing -> y : _) = x+y 
    3737                        -- Equiv to: h ([x]:[y]:_) = ... 
    3838  h other = 0 
     
    6767 
    6868The rule for '''pattern-matching''' is this: 
    69 To match a value ''v'' against a pattern ''($expr -> p)'',  
     69To match a value ''v'' against a pattern ''(expr -> p)'',  
    7070  * Evaluate ''(expr v)'' 
    7171  * If the result is ''(`Just` w)'', match ''w'' against ''p'' 
     
    471471Erwig do no stripping of the `Maybe` (see "Possible extension 2" above). 
    472472 
    473 === [http://lambda-the-ultimate.org/node/1960 Emir, Odersky, Williams: Matching objects with patterns] 
     473=== [http://lambda-the-ultimate.org/node/1960 Emir, Odersky, Williams: Matching objects with patterns] === 
    474474 
    475475Scala is an OO language with lots of functional features.  It has algebraic data types and