Many other readers were confused by this so we'll update the formatting to say "target completion" to make this more clear.
619 karma · joined March 31, 2011
Many other readers were confused by this so we'll update the formatting to say "target completion" to make this more clear.
https://www.dropbox.com/s/7xizuaap0lbjt0k/Screenshot%202016-...
extension Optional {
func try<U>(f: (T) -> U) -> Optional<U> {
if let unwrapped = self {
return f(unwrapped)
} else {
return nil
}
}
}
You can see how to use it in this gist:In ruby, you choose whether to signal and you choose whether to guard. Here are some ruby examples that may be more clear:
Does not signal
user = User.find_by_favorite_dinosaur("Dromiceiomimus")
Does not guard def print_favorite_dinosaur(user)
p "User's favorite dinosaur is #{user.dino})"
end
Signals and guards def print_favorite_dinosaur(user)
if user
p "User's favorite dinosaur is #{user.dino})"
else
p "No user. (Let's assume she likes T-rexs)"
end
end
possible_user = User.find_by_favorite_dinosaur("Dromiceiomimus")
print_favorite_dinosaur(possible_user) def try(*a, &b)
if a.empty? && block_given?
yield self
else
public_send(*a, &b) if respond_to?(a.first)
end
end
https://github.com/rails/rails/blob/d68419a88e424e588c2d8dec...Should be easy to do the same in swift. Let me take a stab at it.
The prize is that we'll use your algorithm to validate any matches that you go on. If that doesn't seem worthwhile to you, feel free to pass on this contest.
You get 1 point for each friendship that you correctly predict did or did not occur. In the test data set ~50% of pairs became friends, so predicting "everyone became friends" would get 250 points, whereas a perfect algorithm would get 500 points.
I'm updating the README now to make our scoring system more clear.
Ubuntu has certainly been a pleasure to use on the cloud. Congratulations to all the contributors.
One thing that I'd like to see is a gutter-based grid system. In your grid examples the inner elements take care of the padding so we end up with weird padding on the left and right.