Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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
>