Prev: image read error
Next: How to fit a curve to an image?
From: Andrew on 25 Feb 2010 23:38 "Brandon" <bnavra.remove.this(a)student.usyd.edu.au.remove.this> wrote in message <gp425t$b6k$1(a)fred.mathworks.com>... > "Brandon" <bnavra.removethis(a)student.usyd.edu.au.removethis> wrote > > a lisp-like calculation system using anonymous functions. > > > Actually, the description lisp-like is not correct. Maybe lambda expression evaluator is a better one Mike, et al., A very interesting thread, but I thought that the point of a fixed point combinator such as the Y combinator was that it transformed a recursive function to a non-recursive function. Yet when I enter the following at the Matlab R2009a prompt: ifthenelse = @(b,varargin) varargin{2-b}(); apply = @(f,x) f(x); Y = @(f) apply(@(g)g(g), @(h)f(@(y) apply(h(h), y))); fact = Y(@(fct)@(n)ifthenelse(n==0 ,@()1, @()n*fct(n-1))); and then type: fact(100) I get the following error: ??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer. Error in ==> @(h)f(@(y)apply(h(h),y)) What's the deal? Is there a bug in the code above or does this have to do with how Matlab is handling function calls and anonymous functions? My eyes hurt from trying to parse this, but it looks like the apply function is calling itself in the definition for Y. Cheers, -- Andrew
|
Pages: 1 Prev: image read error Next: How to fit a curve to an image? |