caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Kirill <kirillkh@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] weird type behavior
Date: Sun, 29 Oct 2006 03:34:49 +0200	[thread overview]
Message-ID: <1162085689.23148.75.camel@nfnl> (raw)
In-Reply-To: <1162084356.23148.64.camel@nfnl>

Here's the same code as in my second message, in shorter and arguably
more readable form. createln function creates a Church's "lambda
number". succ and pred, respectively, produce successive and preceding
numbers to the given.


let rec createln = function
  | 0 -> fun f x -> x
  | n -> fun f x -> f (createln (n-1) f x)
;;

let succ lnum f x = f (lnum f x);;

let pred lnum =
  let calc_last_pair =
    lnum (
      fun pair ->
        let curr = car pair in
          cons (succ curr) curr
    ) (
      cons (createln 0) (createln 0)
    )
  in cdr calc_last_pair
;;


On Sun, 2006-10-29 at 03:12 +0200, Kirill wrote:
> Hi,
> 
> Unfortunately, I wasn't able to infer, how to solve my problem from the
> FAQ, nor from other sources. I can see that partial application somehow
> interferes with polymorphism, and partial application does look
> necessary for my task. Does it mean it's completely impossible in OCaml?
> Or is there still some way to overcome the problem?
> 
> -Kirill
> 
> 
> On Sun, 2006-10-29 at 03:05 +0200, Kirill wrote:
> > On Sat, 2006-10-28 at 17:15 +0100, Richard Jones wrote:
> > > I think the answer to the second part of your question is here:
> > > 
> > > http://caml.inria.fr/resources/doc/faq/core.en.html#eta-expansion
> > > 
> > > Rich.
> > > 


  reply	other threads:[~2006-10-29  1:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-28 15:49 Kirill
2006-10-28 16:12 ` [Caml-list] " Richard Jones
2006-10-28 17:17   ` Kirill
     [not found]   ` <20061028161506.GA2596@furbychan.cocan.org>
     [not found]     ` <1162083950.23148.58.camel@nfnl>
2006-10-29  1:12       ` Kirill
2006-10-29  1:34         ` Kirill [this message]
2006-10-29  5:07         ` skaller
2006-10-29 10:03   ` Boris Yakobowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1162085689.23148.75.camel@nfnl \
    --to=kirillkh@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).