egison-3.6.1: lib/core/base.egi
;;;;;
;;;;;
;;;;; Base
;;;;;
;;;;;
(define $eq
(matcher-dfs
{[,$val []
{[$tgt (if (eq? val tgt)
{[]}
{})]}]
[$ [something]
{[$tgt {tgt}]}]
}))
(define $bool eq)
(define $char eq)
(define $integer eq)
(define $float eq)
;;
;; Utility
;;
(define $id 1#%1)
(define $fst 2#%1)
(define $snd 2#%2)
(define $b.compose
(lambda [$f $g]
(lambda $x
(apply g (apply f x)))))
(define $compose
(cambda $fs
(lambda $x
(foldl 2#(%2 %1) x fs))))
(define $ref
(lambda [$xa $i]
(array-ref xa i)))
(define $eq?/m
(lambda [$a $x $y]
(match x a
{[,y #t]
[_ #f]})))
;;
;; Boolean
;;
(define $and (cambda $bs (foldl b.and #t bs)))
(define $or (cambda $bs (foldl b.or #f bs)))
(define $b.and
(lambda [$b1 $b2]
(if b1
b2
#f)))
(define $b.or
(lambda [$b1 $b2]
(if b1
#t
b2)))
(define $not
(lambda [$b]
(match b bool
{[,#t #f]
[,#f #t]})))