Egison - 模式匹配编程语言


MIT
跨平台

软件简介

Egison 是世界上首个实现了非线性模式匹配的编程语言,用于处理各种不自由的数据类型。如列表、多集合、集合、树和图。

示例代码:

;; Extract all twin primes from the infinite list of prime numbers with pattern-matching!
(define $twin-primes
  (match-all primes (list integer)
    [<join _ <cons $p <cons ,(+ p 2) _>>>
     [p (+ p 2)]]))

;; Enumerate first 10 twin primes
(take 10 twin-primes)
;=>{[3 5] [5 7] [11 13] [17 19] [29 31] [41 43] [59 61] [71 73] [101 103] [107 109]}