3 ms·
You may not like it but this is what peak Computer Science looks like
- kristianp 3y agoI got gpt-4-vision to transcribe the image from that tweet, looks like it's from [1], "Functional programming in OCAML". > This balance function can be written simply and concisely using pattern matching, where each of the four input cases is mapped to the same output case. In addition, there is the case where the tree is left unchanged locally. let balance = function | Black, z, Node (Red, y, Node (Red, x, a, b), c), d | Black, z, Node (Red, x, a, Node (Red, y, b, c)), d | Black, x, a, Node (Red, z, Node (Red, y, b, c), d) | Black, x, a, Node (Red, y, b, Node (Red, z, c, d)) -> Node (Red, y, Node (Black, x, a, b), Node (Black, z, c, d)) | a, b, c, d -> Node (a, b, c, d) val balance : color \* 'a \* 'a rbtree \* 'a rbtree -> 'a rbtree = <fun> [1] https://courses.cs.cornell.edu/cs3110/2021sp/textbook/eff/rb.html https://courses.cs.cornell.edu/cs3110/2021sp/textbook/eff/rb...
- rlupi 3y agoI don't get it. Why would someone not "like it"? Pattern matching is pretty much mainstream now. Ocaml, while not as common, is widely used. I think it's a great choice for teaching functional programming. The book itself (linked in another comment) seems nice, although somewhat a bit general (e.g. a book with a more narrow focus on data structures would touch purely functional data structures, like finger trees) but this is perfect given the course scope. https://courses.cs.cornell.edu/cs3110/2021sp/textbook/intro/history.html https://courses.cs.cornell.edu/cs3110/2021sp/textbook/intro/...
- NikkiA 3y ago> I don't get it. Why would someone not "like it"? "You may not like it, but..." is a stupid meme.