-- GeNeRaTeD fOr: ../../CBS/Funcons/Computations/Control flow/Normal/Iterating/Definite/Filtering collections/map-filter.aterm {-# LANGUAGE OverloadedStrings #-} module Funcons.Core.Computations.ControlFlow.Normal.Iterating.Definite.FilteringCollections.MapFilter where import Funcons.EDSL entities = [] types = typeEnvFromList [] funcons = libFromList [("map-filter",PartiallyStrictFuncon [NonStrict,Strict] stepMap_filter)] -- | -- /map-filter(P,M)/ discards all entries from the map /M/ that do not -- satisify the predicate /P/ . /P/ is given a key/value pair. map_filter_ fargs = FApp "map-filter" (FTuple fargs) stepMap_filter fargs@[arg1,arg2] = evalRules [rewrite1] [] where rewrite1 = do let env = emptyEnv env <- fsMatch fargs [PMetaVar "F",PAnnotated (PMetaVar "M") (TName "values")] env rewriteTermTo (TApp "list-to-map" (TTuple [TApp "list-filter" (TTuple [TVar "F",TApp "map-to-list" (TTuple [TVar "M"])])])) env stepMap_filter fargs = sortErr (FApp "map-filter" (FTuple fargs)) "invalid number of arguments"