flatmap   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/tests/core/algebraic_data_types.xtm

Implementation

;; also known as bind in haskell
(bind-func flatmap:[ADList{!b}*,ADList{!a}*,[ADList{!b}*,!a]*]*
  (lambda (M f)
    ;; alternative 'direct' implementation
    ;; (ADCons$ M (x xs) (append (f x) (flatmap xs f)) (ADNil))))
    (join (fmap f M))))


Back to Index

Similar Entries