Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"[[&g]] (1..100)».&f"

In all fairness you can construct an obtuse example for any programming language.



For the record, this could also be written as

    (1..100).hyper.map(&f).reduce(&g)
Syntactic sugar can make a mess when overused, but also improve readabiliy tremendously when used judiciously.


It's verbatim from the blog post. To be fair, the author is trying to make the point you're making.


The OP is making the point that A) it's extremely easy to read if you know the language and B) it's extremely easy to learn the language and C) it's extremely easy to think something is hard to read just because you don't know the language.

Some hints:

    sub add ($left, $right) { $left + $right }

    add 1,2         # call function add as listop; yields 3
    1 [&add] 2      # use function add as infix; yields 3
    [+] 1,2,3       # sticks + between numbers; yields 6
    [[&add]] 1,2,3  # sticks add between numbers; yields 6

    1..100          # numeric range between 1 and 100
    (1..100)        # so postfix applies to range, not 100
    
    »           # parallelizable map passing values 1..100
    .           # call a method as the mapped function
    &f          # function f gets called 100 times with
                # its first arg values 1..100




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: