Skip to content

Commit b6852ca

Browse files
msullivanbrson
authored andcommitted
---
yaml --- r: 3802 b: refs/heads/master c: 418aa52 h: refs/heads/master v: v3
1 parent 9a7b784 commit b6852ca

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: cd97f4eed04be79ade0e54d867153c554ec54430
2+
refs/heads/master: 418aa525107319a224a3299eae8d9c8fdfe02c13
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// xfail-stage0
2+
3+
fn fix_help[A,B](@fn (@fn (&A) -> B, &A) -> B f, &A x) -> B {
4+
ret f(@bind fix_help(f, _), x);
5+
}
6+
7+
fn fix[A,B](@fn (@fn (&A) -> B, &A) -> B f) -> (@fn(&A) -> B) {
8+
ret @bind fix_help(f, _);
9+
}
10+
11+
fn fact_(@fn (&int) -> int f, &int n) -> int {
12+
// fun fact 0 = 1
13+
ret if (n == 0) { 1 } else { n*f(n-1) };
14+
}
15+
16+
fn main() {
17+
auto fact = fix(@fact_);
18+
assert(fact(5) == 120);
19+
assert(fact(2) == 2);
20+
}

0 commit comments

Comments
 (0)