OASIS Open Mailing List Archives  ·  All Lists  ·  xacml  ·  2002-09

xacml — archive

[Date Prev]  |  [Thread Prev]  |  [Thread Next]  |  [Date Next]   —  [Date Index]  |  [Thread Index]  |  [Month Index]  |  [List Home]

[xacml] Equivalence of Functions


 MHonArc v2.5.2 -->
















xacml message

[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


[Date Prev]  |  [Thread Prev]  |  [Thread Next]  |  [Date Next]   —  [Date Index]  |  [Thread Index]  |  [Month Index]  |  [List Home]