4 ms·
How could I write this in Rust? fun map f [] = [] | map f (x::xs) = (f x) :: map f xs; And boy, no TCO. What a shame.
by throwaway487550 8y ago
How could I write this in Rust?
fun map f [] = []
| map f (x::xs) = (f x) :: map f xs;
And boy, no TCO. What a shame.
- steveklabnik 8y agoYou can only use irrefutable patterns. You’d write this by writing a match in the body. There’s been talk of maybe supporting this directy but it’s so niche there’s not a ton of demand. There is TCO, just not guaranteed. We’d like it; we have even reserved a keyword. Needs an RFC though.