andrewstellman
Joined 9 years ago
Joined 9 years ago
How funny! This is exactly the approach Jenny Greene and I took in Head First C# (O'Reilly), right down to the way we start with cards and suits, then ordering, building up to a complete card game.
Here's an article about my system, pbprdf: https://www.zdnet.com/article/nba-analytics-and-rdf-graphs-g...
And an example of its use: https://gist.github.com/andrewstellman/4872dbb9dc7593e56abdd...
Here's an example of what the RDF files generated by pbprdf look like:
Here's the ontology, which defines the vocabulary it uses: https://github.com/andrewstellman/pbprdf/blob/master/generat...
And this is what the data looks like:
<pbprdf/games/2017-11-29_Warriors_at_Lakers/230> pbprdf:shotPoints "3"^^xsd:int ;
pbprdf:shotAssistedBy <pbprdf/players/Klay_Thompson> ;
pbprdf:shotType "26-foot three point jumper" ;
pbprdf:shotMade "true"^^xsd:boolean ;
a pbprdf:Shot ;
pbprdf:shotBy <pbprdf/players/Stephen_Curry> ;
a pbprdf:Play ;
pbprdf:forTeam <pbprdf/teams/Warriors> ;
pbprdf:inGame <pbprdf/games/2017-11-29_Warriors_at_Lakers> ;
pbprdf:time "10:23" ;
pbprdf:period "3"^^xsd:int ;
a pbprdf:Event ;
rdfs:label "Warriors: Stephen Curry makes 26-foot three point jumper (Klay Thompson assists)" ;
pbprdf:secondsIntoGame "1537"^^xsd:int ;
pbprdf:secondsLeftInPeriod "623"^^xsd:int .I'm pretty sure the researchers were using a normal computer projector and not a slide projector. But in my imagination, they printed a bunch of slides, fed them into a carousel projector, and pointed them at an old Smuckers jelly jar full of resin.
Wait, what? The ability to see through walls and not require line of sight leads to fewer privacy concerns?
Seems to me the privacy concerns are significantly greater for radar than facial recognition. Radar can see places that cameras can't, and while it doesn't capture color information, it does capture detailed 3D data that camera-based systems need to interpolate.
Plus, you know, the whole working through walls thing. Seems like there are at least as many opportunities for abuse as with facial recognition technology.
That said, I think there are several advantages:
• It's more compact, with fewer lines and fewer characters, but at least as readable
• There's simple separation of concerns: it only has a single print statement – the whole range is transformed, then printed – which makes it easy to refactor later if I need to use those values for something other than printing
• It's obvious that all of the cases are handled
• In an amazing coincidence, it looks like code I write :) so I personally prefer it
If you're implying that there are times that if/elif/else syntax is more readable than pattern matching, then yes, absolutely! There are times when one is preferable, and times when the other is.
Pattern matching is especially nice when you need to include conditionals and types:
vehicle match {
case car: Car if (car.passengers > 2) => addToHovLane(car)
case truck: Truck => reject("No trucks allowed")
case _ => totalTraffic += 1
}
There's a lot of casting going on there, and it's all handled in the pattern match. Converting this to if/else statements would require a lot of type tests and intermediate variables. Personally, I think that would make things harder to read.That said, sometimes (often!) the more compact code is, the harder it is to read. I think it's always worth taking a few extra characters to improver readability. So I only use pattern matching with types and discards when I think it makes the code more readable and more flexible (e.g. easier to refactor, improves separation of concerns).
BTW, thanks for pushing back on this. I'm working on the 4th edition of Head First C# (O'Reilly), and C# added syntax very similar to this (borrowed from F#). Writing this reply gave me the opportunity to start thinking through how I want to teach it.
(1 to 100).map(i => (i % 3, i % 5) match {
case (0, 0) => "FizzBuzz"
case (0, _) => "Fizz"
case (_, 0) => "Buzz"
case _ => s"$i"
}).foreach(println)
Compare that to the rest of the examples on the page. The only one that comes close in either readability or compactness (in my opinion) is the Rust example, mainly because it's syntactically almost identical, just a bit more verbose. I'm really excited that C# 8 will support similar syntax with _ discards.It was usually parked in the Field Robotics garage, but if you went out early on a weekend morning, you might catch it driving itself slowly around Schenley Park (which is right next to CMU campus) – without anyone at the wheel, which was really unreal and sci-fi-ish at the time.
I remember one story of a jogger who was surprised to suddenly run across it. The story goes that the he or she screamed and actually fainted. The truck was programmed to stop if it found itself in front of any obstacle, so when the jogger came to, there was the truck looming above.
I have no idea if the story is actually true, but I like it anyway.
https://twitter.com/AndrewStellman/status/107722796317793484...
> I used to think I was the one who had it all figured out. Adventurous life in the city! Traveling the world! Making memories! Now I feel incredibly hollow. And foolish. How can I make a future for myself that I can get excited about out of these wasted years?
I hope she can learn to stop thinking about those years as wasted. She saw and did things that most people never get to see or do because they're too busy working. Plenty of 35-year-olds are in debt, upside-down on their houses, in miserable marriages, and just a few years from getting divorced, buying a convertible, and dating someone inappropriately young for them. More than a few of them would envy her life.
Website: https://www.stellman-greene.com
Twitter: @andrewstellman
Github: https://github.com/andrewstellman/