-- GeNeRaTeD fOr: ../../CBS/Funcons/Computations/Control flow/Normal/Iterating/Definite/Mapping collections/list-map.aterm {-# LANGUAGE OverloadedStrings #-} module Funcons.Core.Computations.ControlFlow.Normal.Iterating.Definite.MappingCollections.ListMap where import Funcons.EDSL entities = [] types = typeEnvFromList [] funcons = libFromList [("list-map",PartiallyStrictFuncon [NonStrict,Strict] stepList_map)] -- | -- /list-map(F,L)/ maps the computation /F/ over the list /L/ , -- from left to right, evaluating /F/ for each given value in /L/ . list_map_ fargs = FApp "list-map" (FTuple fargs) stepList_map fargs@[arg1,arg2] = evalRules [rewrite1,rewrite2] [] where rewrite1 = do let env = emptyEnv env <- fsMatch fargs [PMetaVar "F",PValue (PList [])] env rewriteTo (FList []) rewrite2 = do let env = emptyEnv env <- fsMatch fargs [PMetaVar "F",PValue (PList [VPMetaVar "V",VPSeqVar "V*" StarOp])] env rewriteTermTo (TApp "cons" (TTuple [TApp "left-to-right" (TTuple [TApp "give" (TTuple [TVar "V",TVar "F"]),TApp "list-map" (TTuple [TVar "F",TList [TVar "V*"]])])])) env stepList_map fargs = sortErr (FApp "list-map" (FTuple fargs)) "invalid number of arguments"