Search a list of records: Difference between revisions
Content added Content deleted
Line 1,851: | Line 1,851: | ||
data[Select[StringMatchQ[#name, "A*"] &]][1, "population"]</lang> |
data[Select[StringMatchQ[#name, "A*"] &]][1, "population"]</lang> |
||
=={{header|Nim}}== |
|||
<lang Nim> |
<lang Nim> |
||
To solve this task, we define a template “findIt” similar to the templates provided by the standard library module “sequtils”. As First argument it accepts any collection providing a “pairs” iterator (yielding an index and a value), for instance a sequence (list) or a table (hash). The second argument of the template is a predicate, i.e. an expression containing the “it” variable. |
To solve this task, we define a template “findIt” similar to the templates provided by the standard library module “sequtils”. As First argument it accepts any collection providing a “pairs” iterator (yielding an index and a value), for instance a sequence (list) or a table (hash). The second argument of the template is a predicate, i.e. an expression containing the “it” variable. |