flatmap   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/base/prelude.xtm

Implementation

;; also known as 'bind'
(bind-func flatmap:[List{!b}*,List{!a}*,[List{!b}*,!a]*]*
  (lambda (M f)
    ;; alternate implementation using join and fmap
    ;; (join (fmap f M))))
    (Cons$ M (x xs) (append (f x) (flatmap xs f)) (Nil))))


Back to Index

Similar Entries