Is there a way to get a list of all the dependants of a function in Mathematica?

Suppose we have a function of the general form $ $ f=func(x_1,x_2,x_3,…,x_n)$ $ I am looking for a way to get this function as input and output the list of all dependants, $ $ \{x_1,x_2,x_3,…,x_n\}$ $ For example $ $ sin(x+y)exp(r)+z+xz+y -> \{x,y,r,z\}$ $ How to do that in general for any number of arguments?

Any help much appreciated.

List all column names for multi-joined table

I have a slightly more complicated join:

SELECT person.given_name, person.family_name, person.age, person.sex, person.state,        person.zip, person.street, person.residential_number,        c1.name as citizen_of_country,        c2.name as hospitalization_country,        c3.name as infection_country  FROM patients      JOIN person on patients.person_id = person.id     JOIN country c1 on person."citizenOf_country_id" = c1.id     JOIN country c2 on patients.hospitalized_in_country_id = c2.id     JOIN country c3 on patients.infected_in_country_id = c3.id; 

.. and I’d like to somehow get the name of all columns in this new table. Based on some answers I found, I tried

SELECT DISTINCT column_name FROM information_schema.columns WHERE table_schema = 'public' AND [code]; 

Where [code] is the block above.. But it didn’t work, giving the error “Subquery must return only one column”. I’m new to databases so I’m not sure how to handle this correctly.

How can I sort a nested list?

I have a nested list of the form:

list = {{4., -18., 19.}, {3., 18., -5.}, {-5., -8., -15.}, {-20., 7., -16.}, {10., -13., -7.},         {-12., -9., 17.}, {17., 19., 5.}, {-16., 9., 15.}, {11., -5., -14.}, {18., -10., 13.},         {-3., 11., 12.}, {-6., 17., -8.}, {-18., 14., 1.}, {-19., -15., 10.}, {12., 18., -19.},          {-8., 4., 7.}, {-8., -9., 4.}, {7., 17., -15.}, {12., -7., -14.}, {-10., -11., 8.},         {2., -15., -11.}, {9., 6., 1.}, {-11., 20., -17.}, {9., -15., 13.}, {12., -7., -17.},         {-18., -2., 20.}, {20., 12., 4.}, {19., 11., 14.}, {-16., 18., -4.}, {-1., -17., -19.},         {-13., 15., 10.}, {-12., -14., -13.}, {12., -14., -7.}, {-7., 16., 10.}, {6., 10., 7.},         {20., 14., -16.}, {-19., 17., 11.}, {-7., 1., -20.}, {-5., 12., 15.}, {-4., -9., -13.},         {12., -11., -7.}, {-5., 19., -8.}, {1., 16., 17.}, {20., -14., -15.}, {13., -4., 10.},         {14., 7., 10.}, {-5., 9., 20.}, {10., 1., -19.}, {-16., -15., -1.}, {16., 3., -11.},         {-15., -10., 4.}, {4., -15., -3.}, {-10., -16., 11.}, {-8., 12., -5.}, {14., -6., 12.},         {1., 6., 11.}, {-13., -5., -1.}, {-7., -2., 12.}, {1., -20., 19.}, {-2., -13., -8.},          {15., 18., 4.}, {-11., 14., 9.}, {-6., -15., -2.}, {5., -12., -15.}, {-6., 17., 5.},         {-13., 5., -19.}, {20., -1., 14.}, {9., -17., 15.}, {-5., 19., -18.}, {-12., 8., -10.},          {-18., 14., -4.}, {15., -9., 13.}, {9., -5., -1.}, {10., -19., -14.}, {20., 9., 4.},          {-9., -2., 19.}, {-5., 13., -17.}, {2., -10., -18.}, {-18., 3., 11.}, {7., -9., 17.},         {-15., -6., -3.}, {-2., 3., -13.}, {12., 3., -2.}, {-2., -3., 17.}, {20., -15., -16.},         {-5., -17., -19.}, {-20., -18., 11.}, {-9., 1., -5.}, {-19., 9., 17.}, {12., -2., 17.},         {4., -16., -5.}}; 

I wish to first sort each sublist based on the absolute values(e.g. {4., -16., -5.} => {4., -5., -16.}) and then sort the sublists based on the first followed by the second element (based on absolute values for both the cases).

For example, considering the first 5 sublists the sorted list should be

listSorted5 = {{3., -5., 18.}, {4., -18., 19.}, {-5., -8., -15.},                {-7., 10., -13.}, {7., -16., -20.}} 

How can I do this?

What is the correct pattern to DeleteCases from a list?

I’m trying to get better with pattern matching but even after years of using MMA it’s still a murky concept. The docs are actually pretty good in this regard but I still struggle. In this situation I have a list of real estate items (that are strings) which I’m trying to clean up. I’ve tried the below to methods and have not been able to delete the “HVAC” elements required from this list.

DeleteCases[featureList, StringContainsQ [#,"HVAC"] & ] 

and

DeleteCases[featureList, __~~"HVAC"~~__] 

Both return the same list back:

{ML #,Property Type,SubSpcSqFt,Land Sz SF,Building Type,List Date,Yr Blt,Address,Area,Class,Clear Ceiling Ht (Feet),Lot Frontage (ft),Lot Depth (ft),Zone,Price,Sale Type,Transaction Type,Zoning/Land Use,Amenities-HVAC System,Building Type-Freestanding,HVAC-See Realtor Remarks,HVAC-Baseboard,HVAC-Central A/C,HVAC-Common Water Heater,HVAC-Electric,HVAC-Forced Air,HVAC-Heat Pump,HVAC-Hot Water,HVAC-In-Floor,HVAC-Make-Up Air,HVAC-Mixed,HVAC-None,HVAC-Radiant,HVAC-Rooftop,HVAC-Separate Controls,HVAC-Separate HVAC Units,HVAC-Separate Water Heaters,HVAC-Space Heaters,HVAC-Steam,HVAC-Window A/C} 

What is the correct what to filter out any string containing “HVAC”?

What is the name of the data structure that is a tree on the backend but has a list like API?

I’m looking for the name of a data structure. It is organized like a balanced tree. The elements need not be comparable. Instead of asking if the tree contains a thing (like you would with a collection of comparables), you can query for any k’th element in logarithmic time. You can insert before or after any k’th element. So the API is a bit like a list, except all operations are logarithmic.

I think “rope” might be similar but those seem to be restricted to strings only. It could be thought of as a segment tree, where every leaf has a weight of 1, but instead of storing the weights in the leaves the entry itself is stored.

Making groups out of a list of things based on some similarity

Let’s say I have a list of n items – i1, i2, …, in.

These items are similar to one another based on some similarity function, say similar_func(item_x,item_y) where item_x,item_y belong to list i1, i2, … in. This function returns a number that ranges from 0 to 1, where 0 means not similar at all and 1 means exactly similar.

Now I would like a create a number of groups, each of which may contain items from the above list. Each group having items that are similar to each other items of the group by let’s say 0.5.

I could run a double loop on the list, comparing each item to one another and creating a group whenever I find two items with similarity more than 0.5. Of course I would need to check if the item already exists in a group already created and with all the other items in that group.

This brute force method is possible and will give the right answer.

But I would like to do this more efficiently. Is there a efficient method for solving this problem?

Edit: There can be any number of groups and an item can be in multiple groups.

If similarity(x,y) = 0.6 and similarity(x,z) = 0.6, but similarity(y,z) = 0.4, then there will be two groups -> [x,y] and [x,z]

Also if x is similar to y AND x is similar to z, then it doesnt mean that y is similar to z. The similarity between two items solely depends on the the return value of similarity function when those items are passed as arguments to it.