English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
camlp4 + array
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-10-04 (17:45)
From: blue storm <bluestorm.dylc@g...>
Subject: Re: [Caml-list] camlp4 + array
I suppose you are using the "classical syntax" inside the quotations
(camlp4oof).
You can correct the misbehaviour by switching to the revised syntax
inside the quotations (camlp4orf), but that may require some changes
to your code elsewhere.

I think the easier way to code that with the classical syntax inside
quotations is to use the Ast.exSem_of_list construct :

let quote_int_array arr =
  let quoted_elems = List.map (fun i -> <:expr< $`int:i$ >>)
(Array.to_list arr) in
  <:expr< [| $Ast.exSem_of_list quoted_elems |]$ >>


2009/10/4 Anastasia Gornostaeva <ermine@ermine.pp.ru>:
> Hello.
>
> The code
>
>       let pl =
>            Array.fold_left (fun ls l -> <:expr< $ls$; $`int:l$ >>)
>            <:expr<>> some_array
>          in
>            <:expr< [| $pl$ |] >>
>
> produces somelike [| (1; 2; 3; 4) |], i.e the pl in () brackets.
> How should I do write this code properly?
>
> ermine
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>