# let y = z z ;;
val y : (('_a - '_b) - '_a - '_b) - '_a - '_b = fun
Can anyone get rid of the pesky underscores in the type of y above, so
that it becomes truly polymorphic?
Eta expansion does it...
# let y x = z z x;;
val y : (('a - 'b) - 'a - 'b) - 'a - 'b = fun
Regards,
François
Andrej Bauer andrej.ba...@andrej.com wrote:
What Gerd probably meant was that the usual untyped lambda-calculus
definition of y, which gets us recursion out of nothing isn't typeable
because self-application requires unrestricted recursive types.
Fortunately, even that is not quite correct: Y
Jon Harrop:
On Tuesday 09 February 2010 22:01:03 Gerd Stolpmann wrote:
In the ML community it is consensus that a recursive function is a total
different thing than a non-recursive function...
Note that Standard ML does this differently to CAML/OCaml.
Not quite -- SML simply defines fun f x
Hello,
I was wondering why recursive functions need to be specified with
rec. According to Practical Ocaml, to inform the compiler that the function
exists. But when entering the function definition, can't the compiler note that
the function is being defined so that when it sees the function
Saptarshi Guha a écrit :
Hello,
I was wondering why recursive functions need to be specified with
rec. According to Practical Ocaml, to inform the compiler that the function
exists. But when entering the function definition, can't the compiler note that
the function is being defined so that
Am Dienstag, den 09.02.2010, 15:50 -0500 schrieb Saptarshi Guha:
Hello,
I was wondering why recursive functions need to be specified with
rec. According to Practical Ocaml, to inform the compiler that the function
exists. But when entering the function definition, can't the compiler note
Gerd Stolpmann a écrit :
Am Dienstag, den 09.02.2010, 15:50 -0500 schrieb Saptarshi Guha:
Besides the different way of defining let and let rec there are also
differences in typing.
Which ones?
Gerd
--
Guillaume Yziquel
http://yziquel.homelinux.org/
On Tuesday 09 February 2010 22:01:03 Gerd Stolpmann wrote:
In the ML community it is consensus that a recursive function is a total
different thing than a non-recursive function...
Note that Standard ML does this differently to CAML/OCaml.
--
Dr Jon Harrop, Flying Frog Consultancy Ltd.
Thanks, very helpful.
let f = fun x - x + 1 (1)
let f x = f (f x) (2)
This works in ocaml because, it replaces f (in (2) ) from that of (1).
Which is why i need f previously defined.
Correct me if i'm wrong.
Wouldn't one of way of detecting a recursive function would be to see
if the
let f arg = expr
is just a short-hand notation for
let f = (fun arg - expr)
or, in other words, the anonymous function constructor (fun arg - expr)
is the basic building block to which the let construction is broken
down. The anonymous function has a direct counterpart in the lambda
On Tuesday 09 February 2010 20:50:33 Saptarshi Guha wrote:
Hello,
I was wondering why recursive functions need to be specified with
rec. According to Practical Ocaml, to inform the compiler that the
function exists. But when entering the function definition, can't the
compiler note that the
Am Dienstag, den 09.02.2010, 22:58 +0100 schrieb Guillaume Yziquel:
Gerd Stolpmann a écrit :
Am Dienstag, den 09.02.2010, 15:50 -0500 schrieb Saptarshi Guha:
Besides the different way of defining let and let rec there are also
differences in typing.
Well, at least you can have new
Yes, I see that f isn't recursive, because it simplifies down to
2*(x+1) but for a reader(at least myself) it can be bit tricky to
consume. My experience of reading the /definition/ of a function which
includes a call
to itself is that it is recursive. On the stackoverflow post, you
mentioned
On Tuesday 09 February 2010 22:31:49 Saptarshi Guha wrote:
Yes, I see that f isn't recursive, because it simplifies down to
2*(x+1) but for a reader(at least myself) it can be bit tricky to
consume.
But for a writer it can be useful to produce. For example, imagine a function
in an
Gerd Stolpmann a écrit :
Am Dienstag, den 09.02.2010, 22:58 +0100 schrieb Guillaume Yziquel:
Gerd Stolpmann a écrit :
Am Dienstag, den 09.02.2010, 15:50 -0500 schrieb Saptarshi Guha:
Besides the different way of defining let and let rec there are also
differences in typing.
Well, at least
On 2/10/2010 1:07 AM, Guillaume Yziquel wrote:
Is it possible to have polymorphic recursion with vanilla 'let rec'
invocations?
This is something that Jacques recently merged in the current
development branch. The code below should work with OCaml 3.12.
let length v =
let rec f : 'a. int
On Tue, Feb 9, 2010 at 11:01 PM, Gerd Stolpmann g...@gerd-stolpmann.de wrote:
For defining the operational meaning of a recursive function a special
helper is needed, the Y-combinator. It gets quite complicated here from
a theoretical point of view because the Y-combinator is not typable. But
17 matches
Mail list logo