Mercurial > octave-nkf
comparison test/bug-31371.tst @ 16215:6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
* test/bug-31371.tst, test/bug-36025/@testclass/testclass.m,
test/build-sparse-tests.sh,
test/classes/@CPrecedenceTester2/CPrecedenceTester2.m,
test/classes/@CPrecedenceTester3/CPrecedenceTester3.m,
test/classes/@Cork/click.m, test/classes/@Dork/Dork.m,
test/classes/@Dork/display.m, test/classes/@Dork/gack.m,
test/classes/@Gork/cork.m, test/classes/@Gork/gark.m,
test/classes/@Gork/subsasgn.m, test/classes/@Pork/Pork.m,
test/classes/@Pork/gurk.m, test/classes/@Snork/gick.m,
test/classes/@Spork/geek.m, test/error.tst, test/func.tst, test/index.tst,
test/io.tst, test/line-continue.tst, test/prefer.tst, test/switch.tst,
test/system.tst, test/try.tst: Remove trailing spaces from
ends of lines in test/ directory.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 07 Mar 2013 10:02:13 -0800 |
parents | 1af8d21608b7 |
children |
comparison
equal
deleted
inserted
replaced
16213:b1283d4c06c2 | 16215:6fe6ac8bbfdb |
---|---|
2 %! % Work around MATLAB bug where f(x)(y) is invalid syntax | 2 %! % Work around MATLAB bug where f(x)(y) is invalid syntax |
3 %! % (This bug does not apply to Octave) | 3 %! % (This bug does not apply to Octave) |
4 %! | 4 %! |
5 %! C = @(fcn,x) fcn(x); | 5 %! C = @(fcn,x) fcn(x); |
6 %! C2 = @(fcn,x,y) fcn(x,y); | 6 %! C2 = @(fcn,x,y) fcn(x,y); |
7 %! | 7 %! |
8 %! % Church Booleans | 8 %! % Church Booleans |
9 %! T = @(t,f) t; | 9 %! T = @(t,f) t; |
10 %! F = @(t,f) f; | 10 %! F = @(t,f) f; |
11 %! | 11 %! |
12 %! % Church Numerals | 12 %! % Church Numerals |
13 %! Zero = @(fcn,x) x; | 13 %! Zero = @(fcn,x) x; |
14 %! One = @(fcn,x) fcn(x); | 14 %! One = @(fcn,x) fcn(x); |
15 %! Two = @(fcn,x) fcn(fcn(x)); | 15 %! Two = @(fcn,x) fcn(fcn(x)); |
16 %! Three = @(fcn,x) fcn(fcn(fcn(x))); | 16 %! Three = @(fcn,x) fcn(fcn(fcn(x))); |
17 %! Four = @(fcn,x) fcn(fcn(fcn(fcn(x)))); | 17 %! Four = @(fcn,x) fcn(fcn(fcn(fcn(x)))); |
18 %! | 18 %! |
19 %! % Arithmetic Operations | 19 %! % Arithmetic Operations |
20 %! Inc = @(a) @(f,x) f(a(f,x)); % Increment | 20 %! Inc = @(a) @(f,x) f(a(f,x)); % Increment |
21 %! Add = @(a,b) @(f,x) a(f,b(f,x)); | 21 %! Add = @(a,b) @(f,x) a(f,b(f,x)); |
22 %! Mult = @(a,b) @(f,x) a(@(x) b(f,x),x); | 22 %! Mult = @(a,b) @(f,x) a(@(x) b(f,x),x); |
23 %! Dec = @(a) @(f,x) C(a(@(g) @(h) h(g(f)), @(u) x), @(u) u); % Decrement | 23 %! Dec = @(a) @(f,x) C(a(@(g) @(h) h(g(f)), @(u) x), @(u) u); % Decrement |
24 %! Sub = @(a,b) b(Dec, a); | 24 %! Sub = @(a,b) b(Dec, a); |
25 %! | 25 %! |
26 %! % Renderer - Convert church numeral to "real" number | 26 %! % Renderer - Convert church numeral to "real" number |
27 %! Render = @(n) n(@(n) n+1,0); | 27 %! Render = @(n) n(@(n) n+1,0); |
28 %! | 28 %! |
29 %! % Predicates | 29 %! % Predicates |
30 %! Iszero = @(n) n(@(x) F, T); | 30 %! Iszero = @(n) n(@(x) F, T); |
31 %! | 31 %! |
32 %! % Y combinator implements recursion | 32 %! % Y combinator implements recursion |
33 %! Ycomb = @(f) C(@(g) f(@(x) C(g(g), x)), ... | 33 %! Ycomb = @(f) C(@(g) f(@(x) C(g(g), x)), ... |
34 %! @(g) f(@(x) C(g(g), x))); | 34 %! @(g) f(@(x) C(g(g), x))); |
35 %! | 35 %! |
36 %! Factorial = Ycomb(@(f) @(n) C(C2(Iszero(n), ... | 36 %! Factorial = Ycomb(@(f) @(n) C(C2(Iszero(n), ... |
37 %! @(d) One, @(d) Mult(n, f(Dec(n)))),0)); | 37 %! @(d) One, @(d) Mult(n, f(Dec(n)))),0)); |
38 %! | 38 %! |
39 %! assert (Render (Factorial (Two)), 2) | 39 %! assert (Render (Factorial (Two)), 2) |
40 %! assert (Render (Factorial (Three)), 6) | 40 %! assert (Render (Factorial (Three)), 6) |
41 %! assert (Render (Factorial (Four)), 24) | 41 %! assert (Render (Factorial (Four)), 24) |