let nmap_choose f map = nmap_fold (fun s n v -> match s with None -> if f v then Some n else None | s -> s) None map