0

Is there a way to include the function StringPosition["e"] inside the Query in the following:

query=Query[
    Histogram[Flatten@#]&,
    All,
    First
]@*StringPosition["e"]

There are three functions in use here Histogram[Flatten@#]&, First and StringPosition["e"].

Is there a way to rewrite the query in such a way that when compiled it produces the following:

Normal[query]
StringPosition["e"]/*Map[Map[First]]/*(Histogram[Flatten[#1]]&)

I tried rewriting it like as follows:

query=Query[
    StringPosition["e"]/*(Histogram[Flatten@#]&),
    All,
    First
]

But it doesn't compile to the required form:

Normal[query]
Map[Map[First]]/*StringPosition["e"]/*(Histogram[Flatten[#1]]&)
user13892
  • 9,375
  • 1
  • 13
  • 41
  • 1
    Could you please elaborate on why a nested query is unacceptable? A subquery would be the canonical way to delay the All and First descending operators so that we get the desired compiled form: Normal @ Query[StringPosition["e"]/*Query[Histogram[Flatten@#]&,All,First]]. – WReach Apr 15 '20 at 23:24
  • First query was submitted as an answer to the Day 7 challenge here. – Rohit Namjoshi Apr 16 '20 at 00:51

0 Answers0