[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Subject: [xacml] Equivalence of Functions
foldr f a [] = a foldr f a (x:xs) = ( f a ( foldr f a (x:xs) ) ) You could write sum of a bag of arguments in two ways: sum [] = 0 sum (x:xs) = plus x (sum xs) or sum xs = foldr plus 0 xs however, you can write product like this: product xs = foldr multiply 0 xs You get the functionality of "foldr" without having to define "product" or "sum". -Polar
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Powered by eList eXpress LLC