list - Modify an element in Map -


i have defined types follows:

module smap = map.make(string)  type s =    { t: int     fa: int list }   type t = s smap.t 

i write function modify add 100 list fa element corresponding key. following code works:

let modify (key: string) (x: t) =   let = smap.find key x in   smap.add key { fa = a.fa @ [100] } (smap.remove key x) 

however, removing , adding element looks redundant me... tell me if there better way directly modify it?

yes, can add it.

a map can contain key once, if add mapping key, remove previous one.

http://caml.inria.fr/pub/docs/manual-ocaml/libref/map.make.html#valadd


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -