@@ -1027,9 +1027,9 @@ pure fn lt_42(x: int) -> bool {
1027
1027
Pure functions may call other pure functions:
1028
1028
1029
1029
~~~~ {.xfail-test}
1030
- pure fn pure_length<T>(ls: list <T>) -> uint { /* ... */ }
1030
+ pure fn pure_length<T>(ls: List <T>) -> uint { /* ... */ }
1031
1031
1032
- pure fn nonempty_list<T>(ls: list <T>) -> bool { pure_length(ls) > 0u }
1032
+ pure fn nonempty_list<T>(ls: List <T>) -> bool { pure_length(ls) > 0u }
1033
1033
~~~~
1034
1034
1035
1035
* TODO:* should actually define referential transparency.
@@ -1055,14 +1055,14 @@ An example of a pure function that uses an unchecked block:
1055
1055
~~~~
1056
1056
# import std::list::*;
1057
1057
1058
- fn pure_foldl<T, U: copy>(ls: list <T>, u: U, f: fn(&&T, &&U) -> U) -> U {
1058
+ fn pure_foldl<T, U: copy>(ls: List <T>, u: U, f: fn(&&T, &&U) -> U) -> U {
1059
1059
match ls {
1060
- nil => u,
1061
- cons (hd, tl) => f(hd, pure_foldl(*tl, f(hd, u), f))
1060
+ Nil => u,
1061
+ Cons (hd, tl) => f(hd, pure_foldl(*tl, f(hd, u), f))
1062
1062
}
1063
1063
}
1064
1064
1065
- pure fn pure_length<T>(ls: list <T>) -> uint {
1065
+ pure fn pure_length<T>(ls: List <T>) -> uint {
1066
1066
fn count<T>(_t: T, &&u: uint) -> uint { u + 1u }
1067
1067
unchecked {
1068
1068
pure_foldl(ls, 0u, count)
0 commit comments