02 February 2019

Pattern Matching Wildcard Commentary

While reading Google's Haskell training, I encountered some code for the function (&&), which I thought was mildly unintuitive:

(&&) :: Bool -> Bool -> Bool
True && y = y
_ && _ = False

The reason I found this definition odd is that the author chose to use a wildcard (the first underscore in the second line) instead of the explicit data False. Since Bool only has two choices, True and False, I think explicitly using False instead is more intuitive, since I had to think about the other values that the wildcard can take on besides False. Furthermore, the Haskell compiler, ghc, will validate whether all patterns are matched in the function definition.

Thus, I would rewrite the function as:

True && y = y
False && _ = False


Additional commentary:

Brian Hamrick likes when the wildcard is conceptually a catch-all, i.e.:

True && True = True
_ && _ = False

At first, I thought this best describes the logical truth table, where the only True result is from the inputs (True, True). However, this changes the laziness properties of the function in Haskell: the second argument is forced to evaluate when the first one is True since we do not have enough information to match (AN: this was not obvious to me at first). If the second argument is True, then we match the first line; otherwise, we match the second line, so the second argument gets reduced to weak head normal form (WHNF).


Thanks to Brian Hamrick for help with this expository post.

01 January 2019

18 October 2018

Life is short

My YOLO of the year becomes a little more validated with every passing.

"One ought to enjoy life, really." from things traders say


02 October 2018

An Observation of People's Behaviours

Found in a thread on a car forum. From an acquaintance, who manages a team of 5,000 at a premier technology company:
If I may make an observation -- as someone who manages a team of ~5,000 people in my day job, and thus has the opportunity to see a few patterns of behavior -- you are indicating that you are upset by how some people who aren't you behave towards other people who also aren't you. To be happy in those circumstances will require that everyone behaves the way you wish they would behave, all the time, any time you have or will have the opportunity to observe their behavior. If you can figure out why that's the case -- why it's so important to your happiness that other people behave the way you want them to -- well, the folks I've seen who figure that out are really glad they did afterward.

22 September 2018

tl;dr of What does it take to become a Ferrari VIP?

tl;dr Spend money while building a mutually beneficial relationship.

Here is the acronym presented in the video which describes the four ways of building that relationship:

L - loyalty: within a brand, stick with a dealer.
O - options: almost pure profit for dealers and factory.
V - volume: buy lots of cars; if the dealer needs to move a particular model, do not say no!
E - events: attend events, such as hospitality, racing schools, etc.

17 February 2018

On Mediocrity

Context: What is going on with Counter Logic Gaming in the NA LCS 2018?

The same what is going on with CLG in every esport: mediocrity. 
CLG lost their Dota 2 and CS:GO teams already, somewhat promising, left them in mediocrity till they disbanded. 
This organization doesn't have neither money nor structure to support successful teams.
It really feels like the management is just trying to stay afloat as a brand while spending as little as they can on everything. 
Hell, we lost our team leader/shotcaller cause we couldn't match other teams offers.
When you're okay losing your only star player, a huge brand promoter also, you know you're looking at a zombie organization. 
And to think /r/clg was so delusional when this roster was announced. Sure, what better than 2 players that barely give a damn about winning, barely train in soloq (Stixxay and RO), two very inconsistent solo laners and a timid, barely vocal support together? I'm sad for Biofrost, he's a decent player, our only consistent performer, but he's just the worst fit in this team. We needed Aphro so much. How can you put shotcalling duties on Huhi, a guy that barely understands matchups (legendary losing 1v1 Vlad vs Cassio, as Cassio first and as Vlad after in the same Bo3 versus Liquid last game), half of his roams are a waste of time and used to have the lowest kill partecipation in the league? 
What did management think? That stars were going to align as they did in spring 2016? 
That Piglet was going to throw a game 5 times in a single game again? That Stixxay was forever going to make miracles and not die to Elise cocoons due to how Trist's W works? That lane swaps would've allowed to mask our weankess all time? 
Our run in spring 2016 should've been a warning on how poorly the team was built, but it got masked by the luck we had and the clutch plays of some of our players, but that ended, and now we're 4 splits in a row deep in mediocrity. 
We're 0-8 vs TSM, 1-9 vs IMT/Liquid 2018 and like 2-7 vs C9? 
We're consistently garbage, yet nothing changes. 
I bey my ass the Dardoch problem was Dardoch getting on the team, as competitive as he was pushed everybody to work hard (and look at clg in summer 2017 they started so convincingly)..But no..You can't bother Stixxay with hard work, better remove the jungler. And knowing Dardoch it had to be painful to work with him, when the rest of the team is just "chill, we fine with mediocrity and faith". 
Just smiles, faith memes, patting our team on their shoulders, because after all, it's not even their fault, shit's trickling down from above.

31 December 2017

"We pride ourselves on being fast. Chinese startups are faster."

"Work-life balance is nonexistent in Chinese startups.

Meetings are anytime — really. My meeting in Beijing with Hugo Barra, who runs all international expansion for Xiaomi — the cool smartphone maker and highest-valued startup in China, at around $45 billion or so — was scheduled for 11 pm, but got delayed because of other meetings, so it started at midnight. (Hugo had a flight to catch at 6:30 am after that.)

In China, there is a company work culture at startups that's called 9/9/6. It means that regular work hours for most employees are from 9 am to 9 pm, six days a week. If you thought Silicon Valley has intense work hours, think again.

For founders and top executives, it's often 9/11/6.5. That's probably not very efficient and useful (who's good as a leader when they're always tired and don't know their kids?) but totally common.

Teams get locked up in hotels for weeks before a product launch, where they only work, sleep and work out, to drive 100 percent focus without distractions and make the launch date. And while I don't think long hours are any measure of productivity, I was amazed by the enormous hunger and drive."
From https://www.recode.net/2016/5/13/11592570/china-startup-tech-economy-silicon-valley

16 December 2017

A Number Theory Appetizer

Fix $x, y \in N$ such that $x$ and $y$ are coprime. Prove that there exists $n \in N$ such that $k | x^n - y^n$ for any $k \in N$.

18 May 2017

A C puzzle

Consider the following C code:

#include <stdio.h>

enum bitmask
    bitmask_A = 1,
    bitmask_B = 2,
    bitmask_C = 4
typedef enum bitmask bitmask;

struct a_s
    bitmask member;
typedef struct a_s a_t;

f(a_t *arg)
    arg->member |= bitmask_B;
    return bitmask_C;

    a_t foo;
    foo.member = bitmask_A;
    foo.member |= f(&foo);
    printf("%d\n", foo.member);
    return 0;
What happens?

30 January 2017

A Silly Physics Problem

Brought to you by Tyler Christensen

If you have two ideal 1F capacitors, one at 0V and one at 10V, and you connect them together instantaneously with an ideal superconductor, what is the final voltage? Note all components have zero physical size and there is zero parasitic inductance.