Talk:Search a list of records: Difference between revisions

m
Line 23:
:* 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 all, in fact, compound below the water-line, each with a type/Constructor as well as avarious valueproperties/values/sub-expressions. 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"})()
9,655

edits