Skip to main content
10 votes
Accepted

Why doesn't b = a; f[a_] := b; f[2] return 2?

Caution The post is long. If you just want to know how to fix the code, please search "fix the code in title in 10 ways" in the page. If you want to read discussions about global/local ...
xzczd's user avatar
  • 66.7k
5 votes
Accepted

How to insert a graphics between two points?

First, remove any paddings and margins from res by setting PlotRangePadding -> None, ImagePadding -> 0. Then specify the ...
Domen's user avatar
  • 26.3k
5 votes

Why doesn't b = a; f[a_] := b; f[2] return 2?

I thinks it is pretty obvious why the first code returns a and the second 2. You can see it by comparing ...
azerbajdzan's user avatar
  • 18.7k
4 votes

Why doesn't b = a; f[a_] := b; f[2] return 2?

To understand what is going on you need to look at "DownValues" to see what is actually stored: ...
Daniel Huber's user avatar
  • 52.6k
4 votes
Accepted

Catch error propagation

...
eldo's user avatar
  • 74.4k
3 votes

How can I find all the different ways to group integer numbers from 1 to 10 into 3 lists?

I just found that this can easily be done using KSetPartitions (an external package). Quiet @ Needs["Combinatorica`"]; KSetPartitions[Range[10], 3]
internet's user avatar
  • 793
3 votes
Accepted

Why does this FirstPosition not work?

As written in the documentation for FirstPosition, by default, Heads is set to True. This ...
Domen's user avatar
  • 26.3k
3 votes

Catch error propagation

One strategy could be as follows: ...
Syed's user avatar
  • 55.4k
2 votes

How to retrieve the index of a subset in Subsets[list,nspec,{s}]?

Here's an approach. I'm not 100% confident, but it seems to work on the test cases I've tried. Given a subset, we can turn it into a sort of mask that picks out elements from ...
lericr's user avatar
  • 29k
2 votes

How to retrieve the index of a subset in Subsets[list,nspec,{s}]?

Here is a not too clever solution. We may simply check all answers of Subsets[Range[2000], {4}, {i}] for i=1,2,...: ...
Daniel Huber's user avatar
  • 52.6k
2 votes

How to implement this zip function? zip[g,{f[{a,b}],f[{c,d}]}] to f[{g[{a,c}],g[{b,d}]}]

I can't recall one single built-in function for the task, but here's a simpler solution for your specific task: ...
xzczd's user avatar
  • 66.7k
2 votes

How to implement this zip function? zip[g,{f[{a,b}],f[{c,d}]}] to f[{g[{a,c}],g[{b,d}]}]

I came up with this solution: ...
Tapiocaweasel's user avatar
2 votes

How can I find all the different ways to group integer numbers from 1 to 10 into 3 lists?

res = ResourceFunction["KSetPartitions"][Range[10], 3]; ...
user1066's user avatar
  • 19.4k
2 votes

How can I find all the different ways to group integer numbers from 1 to 10 into 3 lists?

Using function FindClique is pretty fast. FindClique[Graph[UndirectedEdge @@@ edge], {n}, All] contains the groupings for ...
azerbajdzan's user avatar
  • 18.7k
2 votes

How can I find all the different ways to group integer numbers from 1 to 10 into 3 lists?

I have answered a similar question almost 6 years ago. Check this link for more details. However, there is a slight difference in the question here, that is, it does not restrict to a certain grouping ...
Anjan Kumar's user avatar
  • 4,999
1 vote

Distribute arguments over a function in all ordered combinations

list = {a, b, c}; A variant of bmf's answer Using TakeList and Splice (new in 12.1) ...
eldo's user avatar
  • 74.4k

Only top scored, non community-wiki answers of a minimum length are eligible