Person("Smith", 42) 一个经常用于演示函数式语言语法的简单示例。此处以32位非負整數的阶乘函数为例,使用F#。 /// Using patternmatching expression let rec factorial n = match n with | 0 -> 1 | _ -> n * factorial
不同,它可以為被匹配的字串或文本構建複雜的替換。 Wu, Sun; Manber, Udi. Agrep – a fast approximate pattern-matching tool. In Proc. of USENIX Technical Conference. 1992: 153–162 [2021-09-11]