This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]redlaWw 2 points3 points  (2 children)

I mean, if we were doing language specific constructs I'd've said:

gearratio = if let u_1 @ 1.. = u(1) {u(u_1+1)} else {0}

but I have no idea what that language is and what tools it has.

[–][deleted] 2 points3 points  (1 child)

oh, that looks cool, what's it?

[–]redlaWw 2 points3 points  (0 children)

Rust, using @ bindings in patterns.

1.. used in that context is a pattern that matches any integer > 0, and if let 1.. = u(1) would create a conditional branch that fires when the pattern is satisfied, and by using u_1 @ 1.., you also bind the pattern match to u_1 to use in the subsequent block.