7

Is there a simple way to grab or reference one side of an equation?

Minimal example of what I mean:

    eq = x^2==3x
    (*Pseudo Code*)
    in: Grab_lefthandside(eq)
    out: x^2

1 Answers1

4

You can change Equal to List and you will have the list of left and right hand sides of the equation.

First[List @@ (x^2 == 3 x)]
Vahagn Tumanyan
  • 582
  • 2
  • 12
  • 3
    Part, First, Last, etc. operate on expressions not just a List. There is no need to convert to a List to use them. Try f[a, b, c] // First – Bob Hanlon Aug 30 '16 at 15:27
  • That is true. However, I wanted to show how one can extract and manipulate all the objects in an expression. – Vahagn Tumanyan Aug 31 '16 at 05:56