Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
问题是这样的:我知道我需要解析n的出现p,但我也有一个列表xs,我需要从中将一个元素传递给p每个应用程序。传递一个值p很容易parray n (p xs)——但我不知道我需要访问列表中的哪个元素。
n
p
xs
parray n (p xs)
实现这一目标的最干净的方法是什么?
我得出的解决方案是:
let rec pmap f xs = match xs with | x :: xs -> parse { let! y = f x let! ys = pmap f xs return y :: ys } | [] -> parse { return [] }
这可以用作:
let p x = ... pmap p xs
还是想听听其他的想法!