Group Abstract Group Abstract

Message Boards Message Boards

0
|
9.6K Views
|
10 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Apply a function to multiple lists?

Posted 9 years ago
POSTED BY: Brandon Davis
10 Replies
Posted 9 years ago

Hey there,

That is the method I used, the function @@@ expression.

Thanks for the links also!

Best,

Brandon

POSTED BY: Brandon Davis

Hi Brandon, you're using the map function with just 1 argument. that why it doesn't evaluate further. I would suggest you to invest some time on learning the Map and Apply function because they are very frequently used! What helped me was the introduction of Mr Shifrin http://www.mathprogramming-intro.org/ and the video of Mr Gaylord are also very nice http://www.wolfram.com/broadcast/s?sx=gaylord

POSTED BY: l van Veen

You may use Apply with the replaces heads at level 1 shortcut.

costperfish @@@ {{50, 4, 2.5, 2}, {20, 6, 1, 2.5}}

Hope this helps.

POSTED BY: Edmund Robinson
Posted 9 years ago

In using the input:

data := {{50, 4, 2.5, 2}, {20, 6, 1, 2.5}, {30, 5, 1, 2.5}, {20, 7, 1, 2.5}} ;
Map[costperfish[#1, #2, #3, #4] & @@@ data]

I get the output

Map[{1, 4/5, 30/17, 5/9}]

Almost as if Map didn't even do anything. For some reason, I'm having trouble using the Map command, I might just not use it..Thanks again for all your help and patience!

Brandon

POSTED BY: Brandon Davis
Posted 9 years ago

Okay, I see now!

I appreciate your clarification.I haven't used the Map command before but now I see what its doing. Thanks for clearing that up.

Brandon

POSTED BY: Brandon Davis
POSTED BY: l van Veen
Posted 9 years ago
POSTED BY: Brandon Davis
Posted 9 years ago
POSTED BY: Joel Gilly
Posted 9 years ago

Hi, thank you!

I tried this code and it just gives me the same output as the input.. I will mess around with it and get it right sooner or later.

I appreciate the help

POSTED BY: Brandon Davis

Use

Map[costperfish[#]&,{{50,4,2.5,2},{20,6,1,2.5}}]
POSTED BY: l van Veen
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard