(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| {-# LANGUAGE ConstraintKinds #-} | |
| {-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
| module ParserCombinators where | |
| {- | |
| We'll build a set of parser combinators from scratch demonstrating how | |
| they arise as a monad transformer stack. Actually, how they arise as a | |
| choice between two different monad transformer stacks! |
| Introduction | |
| ============ | |
| Futoshiki (不等式, meaning “inequality”) is a Japanese logic puzzle similar to | |
| Sudoku and the like. Numbers from 1 to n must be placed on an n-by-n grid | |
| (which usually already contains some values) such that each row and each column | |
| is a permutation of `[1..n]`. Additionally, less-than or greater-than signs are | |
| placed between cells, constraining their mutual ordering. | |
| An example puzzle looks like this: |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| #include "hemicube.h" | |
| #define PACK_HEMICUBES 1 | |
| static void get_hemicube_face_normal(int index, Vector3 *forward, Vector3 *left, Vector3 *up) { | |
| // Unwrapped hemicube with positive-Z in the middle. | |
| switch (index) { | |
| case 0: *forward = Vector3(+1, 0, 0); *left = Vector3( 0, 1, 0); break; |
| Original text here: https://whydavewhy.com/2013/08/16/loyalty-and-layoffs/ |
Original link: http://www.concentric.net/~Ttwang/tech/inthash.htm
Taken from: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
Reformatted using pandoc
Thomas Wang, Jan 1997
last update Mar 2007
| // Just before switching jobs: | |
| // Add one of these. | |
| // Preferably into the same commit where you do a large merge. | |
| // | |
| // This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
| // and then it quickly escalated into more and more evil suggestions. | |
| // I've tried to capture interesting suggestions here. | |
| // | |
| // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
| // @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
| extern mod extra; | |
| use extra::json::*; | |
| /* | |
| * This function manages to do absolutely no copying, which is pretty cool. | |
| * | |
| * "What are all those `'r`s?" you ask. Well, they're liftime parameters. They | |
| * indicate how long something lasts (before it's freed). They can't change how | |
| * long something lives for, they only allow you to tell the compiler stuff it |