Mercurial > urweb
comparison lib/ur/list.ur @ 1539:dde3bd82cb3d
List.mapXi
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Mon, 15 Aug 2011 10:22:09 -0400 |
parents | ada582d07ae1 |
children | 553a5cc3a4b5 |
comparison
equal
deleted
inserted
replaced
1538:ade93cd5bc59 | 1539:dde3bd82cb3d |
---|---|
131 | x :: ls => <xml>{f x}{mapX' ls}</xml> | 131 | x :: ls => <xml>{f x}{mapX' ls}</xml> |
132 in | 132 in |
133 mapX' | 133 mapX' |
134 end | 134 end |
135 | 135 |
136 fun mapXi [a] [ctx ::: {Unit}] f = | |
137 let | |
138 fun mapX' i ls = | |
139 case ls of | |
140 [] => <xml/> | |
141 | x :: ls => <xml>{f i x}{mapX' (i + 1) ls}</xml> | |
142 in | |
143 mapX' 0 | |
144 end | |
145 | |
136 fun mapM [m ::: (Type -> Type)] (_ : monad m) [a] [b] f = | 146 fun mapM [m ::: (Type -> Type)] (_ : monad m) [a] [b] f = |
137 let | 147 let |
138 fun mapM' acc ls = | 148 fun mapM' acc ls = |
139 case ls of | 149 case ls of |
140 [] => return (rev acc) | 150 [] => return (rev acc) |