New answers tagged

11 votes
Accepted

Maps between finite sets

alist = {3, 4, 5}; blist = {"a", "b"}; mapfs = Tuples@Outer[Rule, blist, alist] $$\begin{array}{l} \{\text{a}\to 3,\text{b}\to 3\} \\ \{\text{...
user avatar
  • 14.9k
6 votes

Maps between finite sets

There's no built-in function but the following constructs the mappings: ...
user avatar
  • 213k
6 votes

Monitoring Apply / @@@ over large lists

Practically speaking, this is what I actually do: First, if I need a variable to be dynamically updated, I use a global foo. Global side effects are generally a ...
user avatar
  • 213k
5 votes

Monitoring Apply / @@@ over large lists

You can do something like: Module[{i}, result = Monitor[ Table[ Pause[0.1]; f @@ i, {i, RandomReal[1, {20, 3}]} ], i ] ] The ...
user avatar
  • 17.9k
15 votes

Monitoring Apply / @@@ over large lists

You can always transform an expression of the form Apply[f,list,level] to the (almost) equivalent Map[Apply[f],list,level]. You ...
user avatar
  • 23.4k
8 votes
Accepted

Monitoring Apply / @@@ over large lists

Probably many ways to do this. For instance, imagine you got a list of large integers list = Table[{RandomInteger[{10^20, 10^21}]}, 10] for which you need to check ...
user avatar
6 votes

How can I apply a function only to even-index elements of a list?

Using Position and Map: ...
user avatar
6 votes

How can I apply a function only to even-index elements of a list?

SubsetMap[dd, arr, 2 ;; -1 ;; 2] (* {1, 3, 3, 5, 5} *) where: arr = {1, 2, 3, 4, 5}; dd[p_] := p + 1 Just for fun ...
user avatar
  • 10.4k
10 votes

How can I apply a function only to even-index elements of a list?

You can use the new ApplyTo: A = {1, 2, 3, 4, 5}; Dd[P_] := P + 1 A[[2 ;; ;; 2]] //= Dd; A (* {1, 3, 3, 5, 5} *)
user avatar
  • 35.7k
11 votes

How can I apply a function only to even-index elements of a list?

I changed D to Dd: MapAt[Dd, A, 2 ;; ;; 2]
user avatar
  • 3,807
8 votes

How can I apply a function only to even-index elements of a list?

alist = {1, 2, 3, 4, 5} Using MapIndexed: ...
user avatar
  • 14.9k
4 votes

Smart way to remove rules from lists, leaving just values, specifically from FindMinimum output

Odds and ends Single and two-variable examples: ...
user avatar
  • 213k
4 votes

Smart way to remove rules from lists, leaving just values, specifically from FindMinimum output

These methods work correctly with any number of variables of any dimensionality: ...
user avatar
7 votes
Accepted

Smart way to remove rules from lists, leaving just values, specifically from FindMinimum output

I want to add this reply in response to the comment written under the OP. The function Values does not work, as all the elements of the list are not rules. (the ...
user avatar
  • 5,684
6 votes

Smart way to remove rules from lists, leaving just values, specifically from FindMinimum output

Let ruleNixer = Rule[_, v_] :> v; Example1 from the docs: FindMinimum[x Cos[x], {x, 2}] {-3.28837, {x -> 3.42562}} <...
user avatar
  • 14.9k
5 votes

Smart way to remove rules from lists, leaving just values, specifically from FindMinimum output

If you're needing to handle output from FindMinimum specifically, then since you know that structure you know how to "re-structure" it: ...
user avatar
  • 3,807

Top 50 recent answers are included