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 applying functions or operators to expressions, especially constructs that take advantage of Map (/@) functionality.
6
votes
Accepted
Efficient way to MapApply for Tensor
However, you should never have to map over indices like this (well, almost never); all your mapping should be doable with Map and Apply directly, both of which take levelspec args. …
2
votes
Accepted
Manipulate mapping on lists
Try using upvalues:
Times[f[x__], f[y__]] ^:= f[x, y]
and then evaluating the expression f[2] f[5] - f[1] f[2] f[5] - ... again.
You could also do it without modifying f and using ReplaceRepeated (// …
0
votes
Restrict kinds of heads when dealing with level concept
.
(* Exact levels {n}: *)
headMap[f_, expr_, head_, {0}] := f[expr]
headMap[f_, expr_, head_, {level_Integer}] :=
Replace[expr, x_head :> Map[headMap[f, #, head, {level - 1}] &, x, {1}]] /; level > … 0
(* Range of levels {n1, n2}: *)
headMap[f_, expr_, head_, {n1_Integer, n2 : (_Integer | Infinity)}] :=
Which[
n2 == 0, f[expr],
n1 == 0,
Construct[f, Replace[expr, x_head :> Map[headMap[f …