* camlp4 + array
@ 2009-10-04 17:08 Anastasia Gornostaeva
2009-10-04 17:44 ` [Caml-list] " blue storm
0 siblings, 1 reply; 2+ messages in thread
From: Anastasia Gornostaeva @ 2009-10-04 17:08 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] camlp4 + array
2009-10-04 17:08 camlp4 + array Anastasia Gornostaeva
@ 2009-10-04 17:44 ` blue storm
0 siblings, 0 replies; 2+ messages in thread
From: blue storm @ 2009-10-04 17:44 UTC (permalink / raw)
To: Anastasia Gornostaeva; +Cc: caml-list
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-10-04 17:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-04 17:08 camlp4 + array Anastasia Gornostaeva
2009-10-04 17:44 ` [Caml-list] " blue storm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox