When I first started baking I used to do a carrot cake which also included grated apple. Every so often the carrots in the cake would turn green just as you described so I changed my recipe to the Hummingbird Bakery recipe, which just uses carrots and walnuts and have perfect results every time (and I use this recipe A LOT!) so I came to the conclusion it must have had something to do with the acid.