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

In Julia, this would be:

1:3 |> x->x+1 |> x->join(x,",") |> length



Small correction (or it won't run on my system):

  1:3 |> x -> map(y -> y+1, x) |> x -> join(x, ",") |> length
All those anonymous functions seem a bit distracting, though https://github.com/JuliaLang/julia/pull/24990 could help with that.


Ok, in Julia 1.0+ you just have to use the dot operator:

1:3 |> x->x.+1 |> x->join(x,",") |> length

Note the dot in x.+1, that tells + to operate on each element of the array (x), and not the array itself.


Ok... not sure which version of Julia you're using, but I'm on 0.5 and it works there... Maybe it changed in a later version


Maybe a bit nicer

    (1:3 .|> x->x+1) |> x->join(x,",") |> length




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

Search: