This is my code
split("hello-world julia", [' ', '-']) .|>
x -> filter(isletter, x) .|>
I want to get the result
"HWJ", but I get a
When I use the
Pipe package, the code works fine. The result is
@pipe split("hello-world julia", [' ', '-']) .|>
filter(isletter, _) .|>
and following code always has an error no matter how many parentheses are added
@pipe split(phrase, [' ', '-']) .|>
filter(isletter, _) |>
filter(x -> length(x) > 0, _) .|>
I’m very confused.
julia> split("hello-world julia", [' ', '-']) .|>
(x -> filter(isletter, x)) .|>
anonymous function (
->) has lower precedence than pipe
I think the Chain.jl syntax is cleaner
using Chain: @chain
@chain "hello-world julia" begin
split([' ', '-'])
There was recently an announcement of new piping package DataPipes.jl by @aplavin.
Wondering if code below is a proper way of writing requested task:
"hello-world julia" |>
split(_, [' ', '-'])
result seems correct at least:
Nice. How do you type the \uparrow?
I am completely confused by this example
No idea what’s going on.
I think it’s the same with
map(x->(a=x, b=x^2, c=1:x), [1,2,3,4]), and return a vector of namedtuple
so u can skip the
x->. Don’t feel this is very intuitive. After skimming thru the documentation, it doesn’t seem to explain that.
The following snippet would be slightly more along the spirit of
split("hello-world julia", [' ', '-'])
I haven’t really considered broadcasting as pipeline steps yet, so unlike regular function calls they don’t enjoy automatic substitution of the previous step results.
This is the whole point of
DataPipes.jl: to get rid of code overhead when using common data processing functions. Such functions typically take a function as their first argument (or arguments, if multiple), and the dataset as the last argument: think
map(_ + 1) translates to
map(x -> x + 1, <previous step result>) and so on.
Agree that the documentation is far from perfect, I just found it easiest for me to put examples showcasing main features instead of extended description.