How do I DistributeDefinitions inside a function?
- To: mathgroup at smc.vnet.net
- Subject: [mg97789] How do I DistributeDefinitions inside a function?
- From: uk.org.microserf at googlemail.com
- Date: Sat, 21 Mar 2009 05:20:47 -0500 (EST)
Hi I have the following function: LeaveOneOut[f_, items_] := Parallelize[ MapIndexed[ f[#1, items[[Complement[Table[i, {i, Length[items]}], #2]]]] &, items]] Which might be called as follows: a = 10 Table[i, {i, 10}]; f[x_, items_] := Mean[items] + x; DistributeDefinitions[a, f]; LeaveOneOut[f, a] Notice that I need to explicitly call DistributeDefinitions. I would like to modify LeaveOneOut such that it performs the DistributeDefinitions call. I've tried a few things=97such as using (Distribute....; Parallelize...) and Module[{}, Distribute....; Parallelize...]=97but the arguments passed to LeaveOneOut don't seem to be being distributed (old definitions are used instead). I'm a relative Mathematica novice, so help=97and an explanation of why what I have already tried doesn't work=97would very much be appreciated! Cheers Chris