Apologies for the large example, the relevant bits are at the top. I included it all so that the curious can easily drop into their favorite thing. Here\'s a playground link