Welcome to our community

Be a part of something great, join today!

Pure function in Map

Barioth

Member
Jan 17, 2013
52
Hi!

Let's say in mathematica I declare this function

t[x_,y_]:= (x'+y')^2

Now I can call it with

\(\displaystyle L=1;\)
t[(#^2)+L &, (#^3)+L &]

if I call it this way it will remplace the # with s and evalute the derivative.

Now let's say I wana do this for for every L from 1 to 10.

so i got

Map[t[(#^2)+# &, (#^3)+# &],Range[1,10]]

and indeed this doesn't work. how can I tell mathematica that I want a # for my function t and one different # to use as my argument in my Map?

(*Note t I know that in this problem in make no sense to change the value of L since we're calculating the derivative. But I want to know for general purpose)
 

Ackbach

Indicium Physicus
Staff member
Jan 26, 2012
4,192
I'm afraid I'm not terribly familiar with pure functions in MMA. However, I do have one question: could you do this in a For loop to get all your L values?
 

Barioth

Member
Jan 17, 2013
52
I'm afraid I'm not terribly familiar with pure functions in MMA. However, I do have one question: could you do this in a For loop to get all your L values?

A for loop would work, altough I want to use this in a Plot or a ListPlot. (I could do it with a For and save what's come out. But I would feel like its a ''Dirty'' solution.)

Thanks for passing by!