Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Questions about Mathematica's procedural programming paradigm.
46
votes
Accepted
Are there any cases when For[] loops are reasonable?
To my mind, there are at least two cases when For loops are ok:
Inside Compile, or in code which is being written with Compile in mind
When your inner loops are vectorized or made efficient by some …
6
votes
Accepted
Functional equivalent of a For loop referring to consecutive elements in a list
Here are two possibilities. First, use MovingMap:
ClearAll[av];
av[{l_, 0, r_}] := (l + r)/2;
av[{_, m_, _}] := m;
and then
smoothMM[list_] := Join[{First@list}, MovingMap[av, list, 3], {Last@lis …