pipeline.scm 543 B

1234567891011121314151617181920212223
  1. (library (pipeline)
  2. (export ->)
  3. (import
  4. (except (rnrs base)
  5. let-values
  6. map
  7. error
  8. vector-map)
  9. (only (guile)
  10. lambda* λ))
  11. (define-syntax ->
  12. (syntax-rules ()
  13. ;; first expression is left unchanged
  14. [(-> expr) expr]
  15. ;; take from the back, wrap other calls
  16. [(-> expr* ... (op args* ...))
  17. (op args* ... (-> expr* ...))]
  18. ;; make parens unnecessary in trivial case of no further arguments
  19. [(-> expr* ... op)
  20. (op (-> expr* ...))])))