Loading ...
Sorry, an error occurred while loading the content.

How to return a user defined type ?

Expand Messages
  • Si Tri Doan
    Dear   I declare of type  type a action= doit of int | takeit of int * a      I need  to write a simple code to take a list of integer and return to a
    Message 1 of 8 , Feb 28, 2010
    • 0 Attachment
      Dear
       
      I declare of type
       type 'a action= doit of int | takeit of int * 'a
       
       
       I need  to write a simple code to take a list of integer and return to 'a action list, i don't know ?
      Can you tell me
      --- Ngày Thứ 2, 22/02/10, Ashish Agarwal <agarwal1975@...> đã viết:


      Từ: Ashish Agarwal <agarwal1975@...>
      Chủ đề: Re: "ocaml_beginners"::[] printf %F format discards significant digits
      Đến: ocaml_beginners@yahoogroups.com
      Ngày: Thứ Hai, 22 tháng 2, 2010, 21:19


      As far as I can tell, %F always prints 6 digits after the decimal point and
      never uses scientific notation, contrary to the documentation. Can anyone
      confirm this?

      Also, %F and %f seem to default to a width of 0 (which makes sense) and a
      precision of 6 (which seems arbitrary, but explains my original example). Is
      this correct?

      Both issues should be clarified in the documentation. I can submit an issue
      in the bug tracker if anyone can confirm. Thank you.


      On Mon, Feb 22, 2010 at 2:38 PM, Florent Monnier <
      fmonnier@...> wrote:

      >
      >
      > Le lundi 22 février 2010 19:53:27, vous avez écrit :
      >
      > > I can rephrase my question. What's the difference between %F and %g?
      >
      > # Printf.printf "%g\n" 3.0 ;;
      > 3
      > - : unit = ()
      > # Printf.printf "%F\n" 3.0 ;;
      > 3.000000
      > - : unit = ()
      >
      >
      > > Both
      > > convert to either decimal or scientific notation. For %g it is specified
      > > that the more compact version will be used, but %F does not specify how
      > the
      > > decision is made and my feeling is it is doing something wrong due to my
      > > original example.
      > >
      > > There is also a bug in the documentation. %e says conversion is to
      > "decimal
      > > notation" but it should be "scientific notation".
      > >
      > > On Sat, Feb 20, 2010 at 12:10 AM, Jon Harrop <jon@...<jon%40ffconsultancy.com>>
      > wrote:
      > > > On Friday 19 February 2010 21:31:12 Ashish Agarwal wrote:
      > > > > The %F format specifier "converts a floating-point argument to Caml
      > > >
      > > > syntax
      > > >
      > > > > (dddd. or dddd.ddd or d.ddd e+-dd)", but how does it decide whether
      > to
      > > >
      > > > use
      > > >
      > > > > scientific notation or not? I expected it to use scientific notation
      > > > > when necessary to avoid discarding significant digits but:
      > > > >
      > > > > # open Printf;;
      > > > > # let x = 1.08100289354652e-219;;
      > > > > val x : float = 1.08100289354652e-219
      > > > > # printf "%F\n" x;;
      > > > > 0.000000
      > > > > - : unit = ()
      > > > >
      > > > > What is the recommended format for minimizing loss of numeric
      > > > > precision? I'm now using %.14e. Thanks.
      > > >
      > > > Read this:
      > > >
      > > > http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html
      > > >
      > > > %f is decimal notation. %e is scientific notation. %g uses the shorter
      > of
      > > > %f
      > > > or %e.
      > > >
      > > > You probably want:
      > > >
      > > > # printf "%0.17g\n" (1.0 +. epsilon_float);;
      > > > 1.0000000000000002
      > > >
      > > >
      > > > --
      > > > Dr Jon Harrop, Flying Frog Consultancy Ltd.
      > > > http://www.ffconsultancy.com/?e
      > >
      > > [Non-text portions of this message have been removed]
      > >
      > >
      > >
      > > ------------------------------------
      >
      > >
      > > Archives up to December 31, 2009 are also downloadable at
      > > http://www.connettivo.net/cntprojects/ocaml_beginners/ The archives of
      > the
      > > very official ocaml list (the seniors' one) can be found at
      > > http://caml.inria.fr Attachments are banned and you're asked to be
      > polite,
      > > avoid flames etc.Yahoo! Groups Links
      > >
      > >
      > >
      >

      >


      [Non-text portions of this message have been removed]



      ------------------------------------

      Archives up to December 31, 2009 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
      The archives of the very official ocaml list (the seniors' one) can be found at http://caml.inria.fr
      Attachments are banned and you're asked to be polite, avoid flames etc.Yahoo! Groups Links






      "Tốt hơn, thoáng gọn hơn, nhanh hơn -Trải nghiệm Yahoo! Mail mới hôm nay!
      http://vn.mail.yahoo.com"

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.