...

jbreckmckye

3115

Karma

2017-03-10

Created

Recent Activity

  • I've also seen (non-GPU) programs use numbers with multiplication, instead of if-else, as a means of preventing CPU branch stalls. This technique is sometimes called branchless programming.

  • Oh, that makes more sense, because ?: has eyes

    https://en.m.wikipedia.org/wiki/Elvis_operator

    ?:-)

  • I'm a big fan of the Elvis operator myself (.?)

  • Floats are an excellent choice because they encode the inevitable ambiguity of the world. Instead of true and false we can have

        true    = 1
        false   = 0
        perhaps = 0.5

  • Now that we have defined a language without booleans, we need some way to coalesce these optional values

    We ideally want an infix function that can reduce the "truthiness" of two values.

    Let us imagine this language is a Haskell-type-thing, and we can define pseudo-operators with pattern matching

        infixr 3 &&
        (&&) :: Optional -> Optional -> Optional
        Empty && _       = Empty
        _ && Empty       = Empty
        Some A && Some B = Some A
        _ && _           = Empty
    
        infixr 2 ||
        Some || _     = Some
        None || Some  = Some
        None || None  = None
        _    || _     = None 
    
    Hmm, let's see how that looks

        a = b && c
        d = e || f
    
    The good news is that we are free from the tyranny of booleans. The bad news is that we just reinvented JavaScript :-)

HackerNews