generic-fusion.lisp 401 B

1234567891011
  1. (import compiler/optimise (fusion/defrule))
  2. (fusion/defrule (map ?f (map ?g ?xs))
  3. (map (builtin/lambda (%x) (?f (?g %x))) ?xs))
  4. (fusion/defrule (filter ?f (filter ?g ?xs))
  5. (filter (builtin/lambda (%x) (cond [(?g %x) (?f %x)] [true false])) ?xs))
  6. (fusion/defrule (reduce ?f ?z (map ?g ?xs))
  7. (reduce (builtin/lambda (%ac %x) (?f %ac (?g %x))) ?z ?xs))