omegaham
Joined 13 years ago
Joined 13 years ago
"Is there a doctor on this plane???"
"Well yes, but I defended my thesis in comparative literature..."
[1] Yes, the ribald jokes have already been made
Match play at the World Championship (where the two players play each other repeatedly for many games) involves a ton of inter-game coaching and work as each player's team goes over what went well, what went wrong, and how the next game should be approached.
Round robin play in small fields also has a significant amount of preparation because the schedule is known in advance, so players will know whom they have to play the following morning and will prepare accordingly.
I'm not comfortable saying that Hikaru does exactly 0 preparation for 3-minute Chess.com blitz games, but it's probably pretty close to 0.
let last xs = List.fold_left (fun x y -> Some y) None xs
This is of type last : 'a list -> 'a option = <fun>
Neat, `'a` is generic. Let's η-reduce out the `xs` and make the function point-free (ignoring the lambda): let last = List.fold_left (fun x y -> Some y) None
This doesn't work the way that we want: last : '_weak1 list -> '_weak1 option = <fun>
The moment that we call this weakly polymorphic function, its type is fixed and is no longer generic. In the toplevel: # last [1;2;3];;
- : int option = Some 3
# last['x';'y';'z'];;
Error: This expression has type char but an expression was expected of type
int
Haskell, of course, is totally happy to let you do point-free mania with Kleisli arrows and all of the rest of it. #include <ranges>
#include <numeric>
#include <vector>
#include <iostream>
int main() {
std::vector<int> vec = {1, 2, 3};
// map, using `std::views::transform`. Implemented in C++20
for(int elem :
std::views::transform(vec, [](int x) { return x + 1; })) {
std::cout << elem << " "; // 2 3 4
}
std::cout << "\n";
// `std::ranges::fold_left` will be available with C++23.
// Until then, we're stuck using the <numeric> iterator version, which was
// implemented in C++20.
std::cout << std::accumulate(vec.begin(), vec.end(), 1,
[](int x, int y) { return x * y; })
<< "\n"; // 6
return 0;
}
Building and running with the following: $ g++ --std=c++20 test.cpp
$ ./a.out
2 3 4
6