0
|
3860 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Is it possible to hide slots in a function?

Posted 9 years ago
 I'm writing some utility functions for manipulating equations. The algebraic manipulation palette doesn't have cross multiplication, for example, which I find a handy manipulation. It it easily implemented as: crossMultiply[a_==b_]:=Numerator[a] Denominator[b]==Numerator[b] Denominator[a]  and can be put at the end of an equation using double slashes. In:= x+y==((-2+y) y)/x^2//crossMultiply Out= x^2 (x+y)==(-2+y) y  If I want to divide both sides of an equation by some expression, I can use divideBy[a_ == b_, divisor_: 1] := a/divisor == b/divisor  I can do this: In:= x^2 == (-2+y)y //divideBy[#,s]& Out= x^2/s == ((-2+y)y)/s  but I'd like to avoid using the slot and ampersand, so that it would look like this;  In:= x^2 == (-2+y)y //divideBy[s] Out= x^2/s == ((-2+y)y)/s  Any ideas?
2 Replies
Sort By:
Posted 9 years ago
 How about: divideByBy[divisor_: 1][a_ == b_] := a/divisor == b/divisor x^2 == (-2 + y) y // divideByBy[s] (* Out= x^2/s == ((-2 + y) y)/s *) x^2 == (-2 + y) y // divideByBy[] (* Out= x^2 == (-2 + y) y *) Regards Henrik
Posted 9 years ago
 Thanks Henrik,That is a new notation for me. So the [a_==b_] automatically takes the stuff to the left of the double slashes just like crossMultiply did. This opens a whole new area to explore.Eric