Message Boards Message Boards

0
|
2931 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Syntax: what's the meaning of &, inside a MovingMap?

Posted 3 years ago

I saw the following code in one example:

quotient[values_, times_] := 
 First[Differences[values]/Differences[times]]

mm = MovingMap[quotient[#BoundaryValues, #BoundaryTimes] &, 
  media, {60, Right}]

I understand it's defining a Pure function quotient which take 2 lists and returns the difference of each element with the next. I can't get why I also need First but the hardest part is in the next line.

I found that #name is called Slot and represents the value associated with key "name" in an association in the first argument.

body& is used to define a pure function... but quotient is already a function...

I can't get the syntax.

POSTED BY: Gianluigi Salvi
3 Replies

Thanks! I wouldn't call it a blog, and it is full of obsolete links, but I am glad that you appreciate it.

POSTED BY: Gianluca Gorni

Thank you very much! I'm glad to see that you are also from Italy, I had a glance at your web site and let me congratulate. It's really interesting and impressive.

POSTED BY: Gianluigi Salvi

It is a special feature of MovingMap, explained in the documentation: #BoundaryValues extracts resampled values at window boundaries, #BoundaryTimes accesses times at window boundaries. In your example, the extracted values are then fed into quotient.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract