HNHacker News
TopNewBestAskShowJobs

rbonvall

941 karma · joined February 14, 2009

Roberto Bonvallet — http://mez.cl/a
submissionscomments
rbonvall··on Ready for changes with Hexagonal Architecture
It's a reference to the Silicon Valley sitcom: https://youtu.be/cB7dInljmO4?t=23
rbonvall··on Unicode 13.0
My wife and I call each other "donkey", and some years ago we used the horse emoji, which was low resolution enough to look as a donkey if you squinted. But modern emojis are too high resolution and it definitely looks like a horse now. So I feel your pain.
rbonvall··on The Knapsack Problem Is All Around Us
A nice solution that is easy to implement in Excel is using a sorting network, that sorts an array by doing the same exchanges for any input. Here I did it just for fun: https://imgur.com/a/qPugrJ6
rbonvall··on Programming Language Checklist
And, for that matter, Perls 0, 1, 2, 3, 4, and 5.

https://perldoc.perl.org/perlhist.html#INTRODUCTION

rbonvall··on I quit social media and now I want a cigarette
Selection bias. You don't find out about the ones that don't share.

I also quit social media and told no one (oops, it seems I just did).

rbonvall··on Go 1.13 Release Notes
But underscores also work for numbers that don't have lot of zeros. Compare:

    12_345_678
    1.2345678e7
rbonvall··on Tired of Stack Overflow
Downvoting already has a small reputation cost: https://stackoverflow.com/help/privileges/vote-down
rbonvall··on Truths programmers should know about case (2018)
While it was customary to omit the accent in uppercase letters due to technical limitations, this is not (and never has been) accepted by the Royal Academy:

http://www.rae.es/consultas/tilde-en-las-mayusculas (link in Spanish).

Personally (I'm a nobody that doesn't always agree with the Academy) I don't like omitting the accents at all in any circumstances.

rbonvall··on Scala 2.13 is now available
You can have the line break appended at the end by using the three-arg version of mkString:

    (header :: rows).mkString("", "\n", "\n")
My two cents: I prefer the second solution. Maybe it's because I have never programmed in Java.
rbonvall··on Rust, Macros, λ-calculus/Church numerals, oh my
I agree, it's nice to use the same symbols you'd use on paper. I did something similar in Scala http://mez.cl/en/lambda-dsl/
rbonvall··on Why GitHub used Haskell for Semantic
Let me add that lenses are not just a Haskell thing. It's a simple (and beautiful IMHO) concept from functional programming that can be introduced in many languages. Also, you can have lenses without the cryptic operators.
rbonvall··on Vim/Neovim Arbitrary Code Execution via Modelines
One use case for modelines was specifying the encoding of the file:

    # vim: set fileencoding=iso-8859-1
Trivia bit: the Python interpreter understands Vim and Emacs modelines as encoding declaration for source files: https://www.python.org/dev/peps/pep-0263/#defining-the-encod...

Another use case was specifying the indentation scheme for the file for weird conventions like "2 space indentation with 4-column tabs" (first level is two spaces, second level is one tab, third level is one tab plus two spaces...)

Fortunately now everything's UTF-8 and weird indentation schemes are uncommon.

rbonvall··on Perl 6's given: switch on steroids
Haskell's syntax is pretty minimal:

  f 0 = doThing
  f 1 = otherThing
  f _ = doDefault
rbonvall··on The Impact of the Lambda Calculus (1997) [pdf]
I prefer to believe this anecdote by Dana Scott: https://youtu.be/SphBW9ILVPU?t=575
rbonvall··on Mathematical Jargon Failures
One I hate is sin^{2}(x) meaning "sine squared" and sin^{-1}(x) meaning "the inverse of the sine function".
rbonvall··on Positional-only Parameters for Python
That feature was removed in python 3:

    $ python2
    >>> def f((a, b)):
    ...   return a + b
    ...·
    >>> f((1, 2))
    3

    $ python3
    >>> def f((a, b)):
       File "<stdin>", line 1
        def f((a, b)):
              ^
    SyntaxError: invalid syntax
rbonvall··on God's Number Is 20 (2010)
It's 2^12 × 3^8 × 8! × 12!
rbonvall··on Touch-typing feels good but isn’t for me
You just made me realize that I cannot either!
rbonvall··on Slack Is Not Where 'Deep Work' Happens
I understand the expectation of having the application open on your workstation while you're at the office, but having notifications enables on your personal phone is not sane.
rbonvall··on K7 Tutorial
I get the same gut reaction as you, but I tried reformatting the code a little bit and it's not _that_ terrible.

From the very little APL I've learnt, I know that operators always have either one parameter (named ω) or two (named α and ω), and their inputs and outputs are always arrays.

If you need to write a lot of such functions, it makes sense to define some macros to help you:

    #define V1(f) A f(w)A w;      // create one-arg function
    #define V2(f) A f(a,w)A a,w;  // create two-arg function
    #define DO(n,x) {I i=0,_n=(n);for(;i<_n;++i){x;}}
iota is the APL equivalent of Python's range function:

    V1(iota) {            // Define one-arg function iota.
        I n = *w->p;          // Get the value of the ω argument.
        A z = ga(0, 1, &n);   // Allocate output array.
        DO(n, z->p[i] = i);   // Assign increasing integers.
        R z;                  // Return the result.
    }
The plus function adds two arrays:

    V2(plus) {            // Define two-arg function plus.
        I  r = w->r,          // Get the rank of ω.
          *d = w->d,          // Get a pointer to ω's data.
           n = tr(r,d);       // Get tne size of ω's data.
        A z = ga(0, r, d);    // Allocate output array.
        DO(n, z->p[i] = a->p[i] + w->p[i]);
                              // Add corresponding values of α and ω
        R z;                  // Return the result.
    }
Personally I cannot tolerate the lack of whitespace, but the APL guys are known to like to see their entire programs in one screenful. I can understand that some people like to write code like this.
rbonvall··on The Perils and Pleasures of Bartending in Antarctica (2017)
Probably those freely distributed condoms are the leftovers from that lady's trip.
rbonvall··on JavaScript Getter-Setter Pyramid
Maybe it should've been called "the getter-setter ziggurat."
rbonvall··on Why you should learn F#
There are some nice examples here: https://fsharpforfunandprofit.com/series/why-use-fsharp.html

I like this one: https://fsharpforfunandprofit.com/posts/designing-for-correc...

rbonvall··on The Yoda of Silicon Valley
Perhaps everyone misheard when he said "you're full of t-shirts."
rbonvall··on Advent of Nim
I have written code to traverse matrices in which I use indices `I` and `J` to iterate over submatrices and indices `i` and `j` to iterate over individual values in a submatrix. Upper/lower case add a new dimension to name things that are related but different.

But is not a deal breaker for me. If the language doesn't let me I can use `ii` or `i2` or whatever.

rbonvall··on UnicodeMath – A Nearly Plain-Text Encoding of Mathematics (2016) [pdf]
Vim digraph feature (ctrl-k) is very convenient for this. Digraphs are two-character mnemonics for symbols. They tend to be easy to remember and they are standardized in RFC 1345 [1].

Greek letters are always a latin letter followed by an asterisk. Arrows and comparison operators are what one would guess. Mathematical symbols generally make some sense:

    <C-k> a *     α
    <C-k> F *     Φ

    <C-k> = >     ⇒
    <C-k> - >     →
    <C-k> > =     ≥

    <C-k> 0 0     ∞
    <C-k> d P     ∂
    <C-k> I n     ∫
[1]: https://tools.ietf.org/html/rfc1345
rbonvall··on How plants evolved to make ants their servants
Yes, article titles have evolved to be clicked.
rbonvall··on The Architecture of Git (2012)
This is from 2012, so it makes more sense to be surprised that it doesn't mention git being a crowdfunded, gamified, phablet-compatible cybertool as-a-service on the cloud.
rbonvall··on Algebra and the Lambda Calculus (1993)
Good catch. Fixed.
rbonvall··on Algebra and the Lambda Calculus (1993)
I don't know if this helps, but the way I see lambda calculus works is that you assemble one expression in which you build all the things you need and then evaluate it to yield a result. After that, everything vanishes from existence.

For example, here I'm building cons, car and cdr just to create a list, from which I'll get its second value:

    (cons => car => cdr =>
    
        // this block is my little world where I have lists
        car(cdr(cons(1)(cons(2)(cons(3)(4)))))
    
    )(  // cons
        carValue => cdrValue => extractor => extractor(carValue)(cdrValue)
    )(  // car
        consValue => (consValue)(x => y => x)
    )(  // cdr
        consValue => (consValue)(x => y => y)
    )
(This is JavaScript-looking lambda calculus, so you can evaluate it in your browser's developer console).
← PreviousPage 4 of 11Next →