Skip to main content
Tweeted twitter.com/StackMma/status/655120327597555712
added 46 characters in body
Source Link
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456

list ={{"AED", 0.27224}, {"AUD", 0.7029}, {"BRL", 0.25138}, {"CAD", 0.7568}, {"CHF", 1.0311}, {"CLP", 0.00144}, {"CNH", 0.15714}, {"CNY", 0.15733}, {"COP", 0.03304}, {"CZK", 0.04148}, {"DKK", 0.1511}, {"EGP", 0.12771}, {"EUR", 1.1272}, {"GBP", 1.52}, {"HKD", 0.12902}, {"HUF", 0.3612}, {"IDR", 0.06828}, {"ILS", 0.25478}, {"INR", 1.5297}, {"JPY", 0.8388}, {"KRW", 0.84796}, {"MAD", 0.10305}, {"MXN", 0.05943}, {"MYR", 0.22635}, {"NOK", 0.11999}, {"NZD", 0.6429}, {"PEN", 0.3097}, {"PHP", 0.02143}, {"PLN", 0.2651}, {"SEK", 0.1202}, {"SGD", 0.6982}, {"THB", 0.02736}, {"TRY", 0.3339}, {"TWD", 0.03044}, {"USD", 1}, {"ZAR", 0.0726}}

list ={{"AED", 0.27224}, {"AUD", 0.7029}, {"BRL", 0.25138}, {"CAD", 
  0.7568}, {"CHF", 1.0311}, {"CLP", 0.00144}, {"CNH", 
  0.15714}, {"CNY", 0.15733}, {"COP", 0.03304}, {"CZK", 
  0.04148}, {"DKK", 0.1511}, {"EGP", 0.12771}, {"EUR", 
  1.1272}, {"GBP", 1.52}, {"HKD", 0.12902}, {"HUF", 0.3612}, {"IDR", 
  0.06828}, {"ILS", 0.25478}, {"INR", 1.5297}, {"JPY", 
  0.8388}, {"KRW", 0.84796}, {"MAD", 0.10305}, {"MXN", 
  0.05943}, {"MYR", 0.22635}, {"NOK", 0.11999}, {"NZD", 
  0.6429}, {"PEN", 0.3097}, {"PHP", 0.02143}, {"PLN", 0.2651}, {"SEK",
   0.1202}, {"SGD", 0.6982}, {"THB", 0.02736}, {"TRY", 
  0.3339}, {"TWD", 0.03044}, {"USD", 1}, {"ZAR", 0.0726}}

using Select[list,#[[1]]=={"AED"|"CNH"|"MAD"|...}]Select[list,#[[1]]=={"AED"|"CNH"|"MAD"|...}]

list ={{"AED", 0.27224}, {"AUD", 0.7029}, {"BRL", 0.25138}, {"CAD", 0.7568}, {"CHF", 1.0311}, {"CLP", 0.00144}, {"CNH", 0.15714}, {"CNY", 0.15733}, {"COP", 0.03304}, {"CZK", 0.04148}, {"DKK", 0.1511}, {"EGP", 0.12771}, {"EUR", 1.1272}, {"GBP", 1.52}, {"HKD", 0.12902}, {"HUF", 0.3612}, {"IDR", 0.06828}, {"ILS", 0.25478}, {"INR", 1.5297}, {"JPY", 0.8388}, {"KRW", 0.84796}, {"MAD", 0.10305}, {"MXN", 0.05943}, {"MYR", 0.22635}, {"NOK", 0.11999}, {"NZD", 0.6429}, {"PEN", 0.3097}, {"PHP", 0.02143}, {"PLN", 0.2651}, {"SEK", 0.1202}, {"SGD", 0.6982}, {"THB", 0.02736}, {"TRY", 0.3339}, {"TWD", 0.03044}, {"USD", 1}, {"ZAR", 0.0726}}

using Select[list,#[[1]]=={"AED"|"CNH"|"MAD"|...}]

list ={{"AED", 0.27224}, {"AUD", 0.7029}, {"BRL", 0.25138}, {"CAD", 
  0.7568}, {"CHF", 1.0311}, {"CLP", 0.00144}, {"CNH", 
  0.15714}, {"CNY", 0.15733}, {"COP", 0.03304}, {"CZK", 
  0.04148}, {"DKK", 0.1511}, {"EGP", 0.12771}, {"EUR", 
  1.1272}, {"GBP", 1.52}, {"HKD", 0.12902}, {"HUF", 0.3612}, {"IDR", 
  0.06828}, {"ILS", 0.25478}, {"INR", 1.5297}, {"JPY", 
  0.8388}, {"KRW", 0.84796}, {"MAD", 0.10305}, {"MXN", 
  0.05943}, {"MYR", 0.22635}, {"NOK", 0.11999}, {"NZD", 
  0.6429}, {"PEN", 0.3097}, {"PHP", 0.02143}, {"PLN", 0.2651}, {"SEK",
   0.1202}, {"SGD", 0.6982}, {"THB", 0.02736}, {"TRY", 
  0.3339}, {"TWD", 0.03044}, {"USD", 1}, {"ZAR", 0.0726}}

using Select[list,#[[1]]=={"AED"|"CNH"|"MAD"|...}]

Source Link
George Wolfe
  • 5.5k
  • 22
  • 43

Using Select with Alternatives

I want to select the elements of a list like:

list ={{"AED", 0.27224}, {"AUD", 0.7029}, {"BRL", 0.25138}, {"CAD", 0.7568}, {"CHF", 1.0311}, {"CLP", 0.00144}, {"CNH", 0.15714}, {"CNY", 0.15733}, {"COP", 0.03304}, {"CZK", 0.04148}, {"DKK", 0.1511}, {"EGP", 0.12771}, {"EUR", 1.1272}, {"GBP", 1.52}, {"HKD", 0.12902}, {"HUF", 0.3612}, {"IDR", 0.06828}, {"ILS", 0.25478}, {"INR", 1.5297}, {"JPY", 0.8388}, {"KRW", 0.84796}, {"MAD", 0.10305}, {"MXN", 0.05943}, {"MYR", 0.22635}, {"NOK", 0.11999}, {"NZD", 0.6429}, {"PEN", 0.3097}, {"PHP", 0.02143}, {"PLN", 0.2651}, {"SEK", 0.1202}, {"SGD", 0.6982}, {"THB", 0.02736}, {"TRY", 0.3339}, {"TWD", 0.03044}, {"USD", 1}, {"ZAR", 0.0726}}

using Select[list,#[[1]]=={"AED"|"CNH"|"MAD"|...}]

but I can't get the list of alternatives to work. Nothing is selected.

Actually, the first list is a list of lists, and there are more alternatives then I shown above.