Skip to content

Add built-in function Distribute #1728

Description

@rocky

Description

Implement Built-in function Distribute[]

Workarounds

Write code in Mathematica? For example:

Distribute[expr_, targetHead_: Plus] := 
  expr /. f_[args___] /; MemberQ[{args}, _targetHead] :> 
    With[{pos = FirstPosition[{args}, _targetHead][[1]]},
      targetHead @@ Map[
        f @@ ReplacePart[{args}, pos -> #] &, 
        Extract[{args}, pos]
      ]
    ]

Distribute[f_[g_Symbol[args___]], g_Symbol] := g @@ (f /@ {args})

Priority

Low

Additional context

This is used in the Combinatorica V2.01 package.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions