# Tag Info

### Position and string patterns

For large lists, this should be snappy: Pick[Range@Length@dat, StringTake[dat, UpTo@4], "star"] and actually, taking advantage of listability, ...
• 25.9k
Accepted

### Position and string patterns

Position[dat, _String?(StringMatchQ[#, "star" ~~ ___] &)] or Position[dat, _String?(StringMatchQ[#, "star*"] &)] or ...
• 399k

### Implementing a Better Grep Command

Mathematica allows text searching using regular expressions (based on the PCRE library). It would take some work to re-implement the whole grep functionality within ...
Accepted

### Searching for an unordered triple in a list of triples

This seems to be a case for OrderlessPatternSequence tT = {{7, 1, 2}, {7, 2, 3}, {7, 3, 8}, {7, 1, 6}}; MemberQ[tT, {OrderlessPatternSequence[1, 2, 7]}] True ...
• 399k

### How can I implement my own documentation search function?

Update This code is no longer the most up-to-date. The properly up-to-date code is in the package on GitHub. For a run-down of the changes between this and that see the discussion between b3m2a1 and ...
• 47k
Accepted

### Find elements of array with largest absolute value

You could use SparseArray to do this: ...
• 131k

### How to find the position of the smaller element in the list?

Flatten @ Position[Less @@@ Transpose[{x, y}], True]
• 24.1k
Accepted

### How to find the position of the smaller element in the list?

Flatten@Position[Negative[x - y], True] Also possible: Flatten@Position[x - y, _?(# < 0 &)] or, as suggested by J.M.,...
• 14.4k

...
• 7,459
Accepted

### Basic Search Functionality

As of Mathematica 11: ...
• 70.9k
Accepted

### Working with deep lists

If there is no particular reason for using Outer, then this is simple and straightforward: ...
• 24.1k
Accepted

### How to cache results of WebImageSearch?

So it looks like the only real way to do this is by hacking the mainframe package that underlies this. Everything seems to be clumsy and hard coded, so I had to dig a little. The following works for ...
• 47k

### How to find the position of the smaller element in the list?

PositionIndex[Sign[x - y]] @ -1 {2, 3, 6} Also PositionIndex[UnitStep[x - y]] @ 0 (* thanks: J.M. *) {2, 3, 6} ...
• 399k

### Find sublists in a list by contents, then union them

Flatten /@ Gather[groups, MemberQ[#1, b | g] && MemberQ[#2, b | g] &]
• 24k
Accepted

### Find sublists in a list by contents, then union them

Using rules: groups //. {a___, x : {___, b | g, ___}, b___, y : {___, b | g, ___}, c___} :> {a, Union[x, y], b, c} This behaves differently compared to your ...
• 70.9k

### Searching a phrase in all *.nb files

A couple of additional solutions. The first, with FindList, is probably the simplest and quickest. Using FindList ...
• 37.9k
Accepted

### Solving a rotating combination lock puzzle

I'd implement backtracking like this: ...
• 70.9k

### Searching a phrase in all *.nb files

Note: the following method isn't robust. See this answer of mine for a robust solution. Here is an approach which does not rely on the NBImport.exe (which actually performs importing of the NB files ...

### Working with deep lists

corey979's answer is simple and elegant for small numbers of values of x, a, and b. But if ...
• 15.3k
Accepted

### Obtaining the position in a list where the i^th element is bigger than the (i+1)^th element

A couple of these methods were incorrect, one terribly so. I believe they are now corrected. Here are some different ideas: ...
• 272k
Accepted

### Find permutation index

I think you'll find this considerably more efficient than the accepted answer: ...
• 25.9k

### Implementing a Better Grep Command

Update As recommended in the comments by @b3m2a1, you can also use RunProcess as a simpler way to execute grep. You need to ...
• 16.4k
Accepted

### How to test if $ⅈ$ is in an expression?

Look at the FullForm. This is what Mathematica actually sees. ...
• 47k
Accepted

### Faster searching for subsets with pairwise conditions

Might be faster to cull as you go. I compile the selection function (possibly it can be made faster). Also I set the history length to zero although that does not help too much because the ...
• 59.6k
Accepted

### Documentation Search : google-like (pokygon -> polygon)

The following is roughly what the documentation search appears to use: We first create an index: index = CreateSearchIndex["ExampleData/Text"] If we now ...
• 34.3k

### Working with deep lists

I think I would use Reap, Sow and Do for this problem. With these functions you can get the ...
• 108k

### Is there a built-in function to do binary search?

It seems that since 2021 there is a ResourceFunction that does this. Example: ResourceFunction["BinarySearch"][{1, 2, 5, 5, 7, 12}, 6] I looked at the ...
• 5,947

...
• 39k