# Question:Does there exist a generalized ListTools:-SearchAll/StringTools:-SearchAll in Maple?

## Question:Does there exist a generalized ListTools:-SearchAll/StringTools:-SearchAll in Maple?

Maple 2023

There seems to be a consensus about using `ListTools:-SearchAll` to locate an item in a list. However, this subroutine does not work on other expressions; A simple instance is that “ListTools:-SearchAll(1, [[1], 1]);” only outputs 2 while what I need is [[1, 1], [2]] (because both “op([1, 1], [[1], 1])” and “op([2], [[1], 1])” are 1). And actually, I hope that there is a more general version in Maple.
For example, I intend to do something like

```restart;
expr, elem := ToInert(eval(`print/Diff`)), '_Inert_NAME'("_syslib"):
SearchAll(elem, expr);
```

and

```List:=[[[[cS,[[[cS,cS],cS],[[[cS,cS],[[cK,cK],cS]],cS]]],cS],cS],[[[cS,[[cK,cS],cK]],cK],cS]]:
items:=Or([[[identical(cS),anything],anything],anything],[[identical(cK),anything],anything]):
SearchAll(items,List); ```

In other words, I need all positions of an operand of an expression (cf. `op`).

It may be manually checked that the "indices" of elem in expr include [5,1,1,2,1,1,1,2,1,2,1,2], [5,1,2,2,1,1,1,1,2,1,2], and [5,2,2,1,1,3,1,2], since

```patmatch(op([5, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2], expr), elem);
=
true

patmatch(op([5, 1, 2, 2, 1, 1, 1, 1, 2, 1, 2], expr), elem);
=
true

patmatch(op([5, 2, 2, 1, 1, 3, 1, 2], expr), elem);
=
true

```

Similarly, after some manual searchs,

```[[1], [1, 1, 1, 2], [1, 1, 1, 2, 2], [1, 1, 1, 2, 2, 1, 2], [2], [2, 1, 1, 2]]:
convert(typematch~(map2(`?[]`, List, `%`), items), `and`);
=
true

```

It turns out that all "indices" in List of items are [1][1,1,1,2][1,1,1,2,2][1,1,1,2,2,1,2][2], and [2,1,1,2].
But isn't there such a SearchAll command that can eliminate the need to manually retrieve them?

﻿