head-strict

head-strict

(theory)A head-strict function will not necessarily evaluateevery cons cell of its (list) argument, but whenever it doesevaluate a cons cell it will also evaluate the element in thehead of that cell. An example of a head-strict function is

beforeZero :: [Int] -> [Int]beforeZero [] = []beforeZero (0:xs) = []beforeZero (x:xs) = x : beforeZero xs

which returns a list up to the first zero.

This pattern of evaluation is important because it is commonin functions which operate on a list of inputs.

See also tail-strict, hyperstrict.