[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test_bug_31371
From: |
Tatsuro MATSUOKA |
Subject: |
Re: test_bug_31371 |
Date: |
Mon, 6 Feb 2012 09:47:42 +0900 (JST) |
Hello
The previous mail has a careless mistake.
The below is the test_bug_31371 result on Ubuntu.
On MinGW, the result is the same.
Regards
Tatsuro
>>>>> processing test_bug_31371
***** test
% Work around MATLAB bug where f(x)(y) is invalid syntax
% (This bug does not apply to Octave)
C = @(f,x) f(x);
C2 = @(f,x,y) f(x,y);
% Church Booleans
T = @(t,f) t;
F = @(t,f) f;
% Church Numerals
Zero = @(f,x) x;
One = @(f,x) f(x);
Two = @(f,x) f(f(x));
Three = @(f,x) f(f(f(x)));
Four = @(f,x) f(f(f(f(x))));
% Arithmetic Operations
Inc = @(a) @(f,x) f(a(f,x)); % Increment
Add = @(a,b) @(f,x) a(f,b(f,x));
Mult = @(a,b) @(f,x) a(@(x) b(f,x),x);
Dec = @(a) @(f,x) C(a(@(g) @(h) h(g(f)), @(u) x), @(u) u); % Decrement
Sub = @(a,b) b(Dec, a);
% Renderer - Convert church numeral to "real" number
render = @(n) n(@(n) n+1,0);
% Predicates
iszero = @(n) n(@(x) F, T);
% Y combinator implements recursion
Y = @(f) C(@(g) f(@(x) C(g(g), x)), ...
@(g) f(@(x) C(g(g), x)));
Factorial = Y(@(f) @(n) C(C2(iszero(n), ...
@(d) One, @(d) Mult(n, f(Dec(n)))),0));
assert (render(Factorial(Two), 2))
assert (render(Factorial(Three), 3))
assert (render(Factorial(Four), 12))
!!!!! test failed
value on right hand side of assignment is undefined
--- On Mon, 2012/2/6, Tatsuro MATSUOKA > wrote:
> >>>>> processing test_bug_31371
> ***** test
> % Work around MATLAB bug where f(x)(y) is invalid syntax
> % (This bug does not apply to Octave)
> C = @(f,x) f(x);
> C2 = @(f,x,y) f(x,y);
>
> % Church Booleans
> T = @(t,f) t;
> F = @(t,f) f;
>
> % Church Numerals
> Zero = @(f,x) x;
> One = @(f,x) f(x);
> Two = @(f,x) f(f(x));
> Three = @(f,x) f(f(f(x)));
> Four = @(f,x) f(f(f(f(x))));
>
> % Arithmetic Operations
> Inc = @(a) @(f,x) f(a(f,x)); % Increment
> Add = @(a,b) @(f,x) a(f,b(f,x));
> Mult = @(a,b) @(f,x) a(@(x) b(f,x),x);
> Dec = @(a) @(f,x) C(a(@(g) @(h) h(g(f)), @(u) x), @(u) u); % Decrement
> Sub = @(a,b) b(Dec, a);
>
> % Renderer - Convert church numeral to "real" number
> render = @(n) n(@(n) n+1,0);
>
> Hello
>
> I have built the source of development branch on both MinGW and Ubuntu.
> (changeset 14333:6dd710b73150)
>
> For both cases, test_bug_31371 gave FAIL
>
> % Predicates
> iszero = @(n) n(@(x) F, T);
>
> % Y combinator implements recursion
> Y = @(f) C(@(g) f(@(x) C(g(g), x)), ...
> @(g) f(@(x) C(g(g), x)));
>
> Factorial = Y(@(f) @(n) C(C2(iszero(n), ...
> @(d) One, @(d) Mult(n, f(Dec(n)))),0));
>
> assert (render(Factorial(Two), 2))
> assert (render(Factorial(Three), 3))
> assert (render(Factorial(Four), 12))
> !!!!! test failed
> value on right hand side of assignment is undefined
>
>
> Regards
>
> Tatsuro
>
- test_bug_31371, Tatsuro MATSUOKA, 2012/02/05
- Re: test_bug_31371,
Tatsuro MATSUOKA <=