Talk:Search a list of records

From Rosetta Code

The BugMeNot junk "task" assault (from behind a login control evasion service) continues :-)

Someone's desk job to establish beachhead positions ?

Maybe, but the credentials should not be as important as the content. Deleting due to the use of BugMeNot isn't a very good reason for deletion, although in these cases the content isn't so good either (but may be improvable; it is wiki so anyone can and should make such improvement please). --Zzo38 (talk) 19:53, 9 October 2015 (UTC)

draft task

Please see Add a Task and if you are more generally interested, check out the "Ways to Contribute" column on the home page. --Rdm (talk) 04:49, 10 October 2015 (UTC)

perhaps 2/3 slight expansions of the task description and requirements ?

The references to:

  1. homogenous vs heterogenous lists, and
  2. looking for elements of two different types

both allude to the implicit presence of specific matching/equality functions.

To get a good Rosetta task, in which comparison across languages makes the hidden convergences and divergences a bit more visible, and intelligible, perhaps ask submitters to show:

  • The behaviour of the implicit equality function used by any built-in search function. (Case sensitive ? Int values = real values ? Expressions evaluated before the match ?)
  • Show a search function which takes a coder-supplied equality function as an argument. (Finding by a particular property, given a list/array of objects (or otherwise compound elements), for example)
  • A search which returns an index, and a search which return a value.

(As a footnote on apparent divergence and hidden convergence, Haskell, at first sight, doesn't use heterogenous lists, but it does use homogenous lists of compound data types. JavaScript appears to have heterogenous list of elements, which might include a mixture of reals, strings, functions, and objects, but in fact these are all JS objects, some atomic on the surface but in all compound below the water-line, each with a type/Constructor as well as a value. Searching for an item will always involve a function which derives a type-dependent value and applies a particular type of equality check, often involving some kind of reduction, normalisation or coercion.

Search also varies with evaluation strategy – if one element of a list is a function call, in some languages that call will be eagerly reduced/evaluated before the search equality function is applied. In others, such as JavaScript, an .indexOf search will not match a string like "epsilon" with a potentially equivalent function call like (function () {return "epsilon"})() It might be helpful to specify requirements which drew these things out and made them visible.