Calculate Pure Function in Map - Mathematica

  • Context: Mathematica 
  • Thread starter Thread starter Barioth
  • Start date Start date
  • Tags Tags
    Function Map Pure
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
Barioth
Messages
47
Reaction score
0
Hi!

Let's say in mathematica I declare this function

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

Now I can call it with

$$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)
 
Physics news on Phys.org
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?
 
Ackbach said:
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!