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

4898Re: "ocaml_beginners"::[] unbound value

Expand Messages
  • Jonathan Bryant
    Nov 1 7:32 AM
    • 0 Attachment
      On Tue, 2005-11-01 at 10:16, Java wrote:
      > I'm getting crazy {O.o}
      > first of all a very beginner question:
      > writing "let rec search x tree" is the same as "let rec search
      > (x,tree)"???? (if not pleas someone explain me the difference

      No, it is not. (x, tree) is a tuple, which is a single
      type/entity/whatever word you want to use. parenthesis and commas are
      not used in OCaml to separate parameters like in other languages.

      let rec search x tree

      yields the type

      val search : 'a -> 'a tree -> 'a tree.

      let rec search (x, tree)

      yields the type

      let rec search ('a, 'a tree) -> 'a tree

      One (the first one) takes two parameters: an 'a and an 'a tree. The
      other (the second one) takes one parameter: a tuple of an 'a and an 'a
      tree. Subtle, but important, difference.

      > and then, I write a code like this:
      > --interface--
      > val insert: 'a * 'a tree -> 'a tree
      > --implementation
      > let rec insert x tree = function
      > | Empty -> Node(x, Empty, Empty)
      > | Node (y, left, right) ->
      > if (x >= y) then Node(y, left, insert x right)
      > else Node(y, insert x left, right)
      > and the compiler says to me:
      > "This expression has type 'a tree -> 'a tree but is here used with
      > type
      > 'a tree"
      > why??
      > thanks
      > Segolas
      > p.s.
      > and tomorrow I'm going to take the exam of theese things...
      > Archives up to August 22, 2005 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.
      > ______________________________________________________________________
      > 1. Visit your group "ocaml_beginners" on the web.
      > 2. To unsubscribe from this group, send an email to:
      > ocaml_beginners-unsubscribe@yahoogroups.com
      > 3. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
      > Service.
      > ______________________________________________________________________
      --Jonathan Bryant
      Student Intern
      Unix System Operations
      VSU Information Technology

      "Das Leben ohne Music ist einfach ein Irrtum, eine Strapaze, ein" Exil."
      ("Life without music is simply an error, a pain, an exile.")
      --Frederich Nietzsche

      "The three cardinal values of a programmer are laziness, impatience, and
      --Perl Man Page
    • Show all 15 messages in this topic