Skip to main content
added 202 characters in body
Source Link
lericr
  • 39.5k
  • 2
  • 23
  • 100

This is probably not a satisfactory answer, but you'll need to provide more context. The short answer is, "yes":

Map[F, c d, {0}] (* F[c d] *) 

But I'm suspicious that this isn't what you want, because it doesn't generalize well. For example, going back to your first input:

Map[F, a + b + c d, {0}] (* F[a + b + c d] *) 

So, what we really need is to understand what your semantics are. If you want a sort of "universal" solution, then you'll need to describe what's "universal" about your inputs. Or maybe that doesn't matter, and this ad hoc approach is fine. I'd need more info.

Update

Actually, I guess you did provide semantics and I was over-indexing on Map. Yeah, distributing over sums but not products is sort of the definition of Distribute per @kglr's comment.

This is probably not a satisfactory answer, but you'll need to provide more context. The short answer is, "yes":

Map[F, c d, {0}] (* F[c d] *) 

But I'm suspicious that this isn't what you want, because it doesn't generalize well. For example, going back to your first input:

Map[F, a + b + c d, {0}] (* F[a + b + c d] *) 

So, what we really need is to understand what your semantics are. If you want a sort of "universal" solution, then you'll need to describe what's "universal" about your inputs. Or maybe that doesn't matter, and this ad hoc approach is fine. I'd need more info.

This is probably not a satisfactory answer, but you'll need to provide more context. The short answer is, "yes":

Map[F, c d, {0}] (* F[c d] *) 

But I'm suspicious that this isn't what you want, because it doesn't generalize well. For example, going back to your first input:

Map[F, a + b + c d, {0}] (* F[a + b + c d] *) 

So, what we really need is to understand what your semantics are. If you want a sort of "universal" solution, then you'll need to describe what's "universal" about your inputs. Or maybe that doesn't matter, and this ad hoc approach is fine. I'd need more info.

Update

Actually, I guess you did provide semantics and I was over-indexing on Map. Yeah, distributing over sums but not products is sort of the definition of Distribute per @kglr's comment.

Source Link
lericr
  • 39.5k
  • 2
  • 23
  • 100

This is probably not a satisfactory answer, but you'll need to provide more context. The short answer is, "yes":

Map[F, c d, {0}] (* F[c d] *) 

But I'm suspicious that this isn't what you want, because it doesn't generalize well. For example, going back to your first input:

Map[F, a + b + c d, {0}] (* F[a + b + c d] *) 

So, what we really need is to understand what your semantics are. If you want a sort of "universal" solution, then you'll need to describe what's "universal" about your inputs. Or maybe that doesn't matter, and this ad hoc approach is fine. I'd need more info.