0
$\begingroup$

I'm using a construct (more complex in fact as the value_ should take a list) to select some entries from an association with criteria:

g[assoc_, value_]:= Select[(#column == value)&][assoc]

As you can see, column name is 'hardcoded', so it literally must be in assoc. Is there a proper way to pass arbitrary column_ name to function construct?

g[assoc_, value_, column_]

Now I could do some g[assoc_, value_, #column] but it seems ugly, and MMA marks it. Would be nice to combine somehow # with variable name. Or some workaround?

$\endgroup$
4
  • 1
    $\begingroup$ #[column] == value? $\endgroup$
    – Kuba
    Jan 15, 2018 at 13:40
  • $\begingroup$ @Kuba. Brilliant! It works))) Thank you! Should I delete it? $\endgroup$
    – iot
    Jan 15, 2018 at 13:43
  • $\begingroup$ Question is slightly different but it boils down to the same thing. Let me know if you disagree with marking it duplicate. $\endgroup$
    – Kuba
    Jan 15, 2018 at 20:40
  • $\begingroup$ @Kuba, I'm fine with dup $\endgroup$
    – iot
    Jan 15, 2018 at 21:06

0