[cduce-users] a generic update(map) function
freeman2004 at gmail.com
Tue Nov 23 02:24:34 CET 2004
> > let updateSalary (Any -> Any)
> > |<salary> [(x & Int)] -> <salary> [ (increase x) ]
> > |<(y)> x & [_*] -> <(y)> (map x with z -> updateSalary z)
> > |x -> x
> BTW, to iterate over XML trees there is the xtransform iterator.
ah... yes. but xtransform takes a sequence rather than an element as parameter,
making the function need two cases rather than one as I expected:
let updateSalary (<_>[_*] -> <_>[_*])
| <salary> [(x & Int)] -> <salary> [ (increase x) ]
| <(y)> x -> <(y)> (xtransform x with <salary> [(x & Int)] ->
[<salary> [ (increase x) ] ] )
am I missing something?
And further, I was wondering if the syntax allows making <salary> also
(I am also looking at Pattern Calculus which allows patterns to be parameters.)
let updateSalary (Any -> Any) (p, x)
match x with
| <(p)> [(x & Int)] -> <(p)> [ (increase x) ]
| ... ...
More information about the Cduce-users