How to use `Anonymous Function` in `Function Piping`?

I think the main issue with your code segment is that you didn’t use a dot to broadcast the operation over the range and perform it elementwise

1:5 |> x -> x^2 # Will error, squaring a range not defined

1:5 .|> x -> x^2 # OK, passes each element of range into function

1:5 |> x -> x.^2 # also ok
3 Likes