-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We were only using it in a single place, and there for no discernable reason (probably as part of the bare-fn-vals-are-not-copyable plan). It seems more surprising than useful.
- Loading branch information
Showing
9 changed files
with
18 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
fn fix_help<A, @B>(f: @fn(@fn(A) -> B, A) -> B, x: A) -> B { | ||
ret f(@bind fix_help(f, _), x); | ||
fn fix_help<A, @B>(f: fn(fn(A) -> B, A) -> B, x: A) -> B { | ||
ret f(bind fix_help(f, _), x); | ||
} | ||
|
||
fn fix<A, @B>(f: @fn(@fn(A) -> B, A) -> B) -> @fn(A) -> B { | ||
ret @bind fix_help(f, _); | ||
fn fix<A, @B>(f: fn(fn(A) -> B, A) -> B) -> fn(A) -> B { | ||
ret bind fix_help(f, _); | ||
} | ||
|
||
fn fact_(f: @fn(int) -> int, n: int) -> int { | ||
fn fact_(f: fn(int) -> int, n: int) -> int { | ||
// fun fact 0 = 1 | ||
ret if n == 0 { 1 } else { n * f(n - 1) }; | ||
} | ||
|
||
fn main() { | ||
let fact = fix(@fact_); | ||
let fact = fix(fact_); | ||
assert (fact(5) == 120); | ||
assert (fact(2) == 2); | ||
} |