Re: Print set and maps
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <CAMu2m2JJPwWScUK2L0sHLco-aQL=0GCDppMhB8dXnZ9cYU3nNA@mail.gmail.com> |
Core provides functions to convert from and to s-expressions for most data
types it has. Maybe you'll be happy with that, but it depends on your
needs. For example:
# let x = String.Map.of_alist_exn [("a",1); ("b",2)];;
val x : int String.Map.t = <abstr>
# String.Map.sexp_of_t sexp_of_int x |> Sexp.to_string_hum;;
- : string = "((a 1) (b 2))"
On Wed, Jun 24, 2015 at 1:10 AM, Johan Mazel [email protected]
[ocaml_beginners] <[email protected]> wrote:
>
>
> Hi
> Is there any standard way to generate strings that contain the content of
> sets/maps (standard, Batteries or Core) ?
> I wrote several to_string functions (either using the print function of
> Batteries or just by converting type to lists and then printing it with the
> BatList module's print function) for these types.
> I however would rather use something from the library instead (especially
> for Core). I tried to read the doc (
> https://ocaml.janestreet.com/ocaml-core/latest/doc/) but I did not get
> any results.
> Is there anything that would do the job ?
> Thank you for your time.
> Johan
>
>
>
>
>